-
Notifications
You must be signed in to change notification settings - Fork 899
/
HelloConfiguration.java
42 lines (34 loc) · 1.63 KB
/
HelloConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package example.springframework.boot.minimal;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.linecorp.armeria.server.Server;
import com.linecorp.armeria.server.docs.DocService;
import com.linecorp.armeria.server.logging.AccessLogWriter;
import com.linecorp.armeria.server.logging.LoggingService;
import com.linecorp.armeria.spring.ArmeriaServerConfigurator;
/**
* An example of a configuration which provides beans for customizing the server and client.
*/
@Configuration
public class HelloConfiguration {
/**
* A user can configure a {@link Server} by providing an {@link ArmeriaServerConfigurator} bean.
*/
@Bean
public ArmeriaServerConfigurator armeriaServerConfigurator(HelloAnnotatedService service) {
// Customize the server using the given ServerBuilder. For example:
return builder -> {
// Add DocService that enables you to send Thrift and gRPC requests from web browser.
builder.serviceUnder("/docs", new DocService());
// Log every message which the server receives and responds.
builder.decorator(LoggingService.newDecorator());
// Write access log after completing a request.
builder.accessLogWriter(AccessLogWriter.combined(), false);
// Add an Armeria annotated HTTP service.
builder.annotatedService(service);
// You can also bind asynchronous RPC services such as Thrift and gRPC:
// builder.service(THttpService.of(...));
// builder.service(GrpcService.builder()...build());
};
}
}