Package com.linecorp.armeria.server
Interface Service<I extends Request,O extends Response>
- Type Parameters:
I- the type of incomingRequest. Must beHttpRequestorRpcRequest.O- the type of outgoingResponse. Must beHttpResponseorRpcResponse.
- All Superinterfaces:
Unwrappable
- All Known Subinterfaces:
GraphqlService,GrpcService,HttpService,HttpServiceWithRoutes,RpcService,RpcServiceWithRoutes,ServiceWithRoutes<I,,O> TransientHttpService,TransientRpcService,TransientService<I,O>
- All Known Implementing Classes:
AbstractGraphqlService,AbstractHttpService,AbstractThrottlingService,AbstractUnaryGrpcService,AbstractUnsafeUnaryGrpcService,AuthService,BraveService,ContentPreviewingService,CoroutineContextService,CorsService,DecodingService,DecoratingService,DocService,EncodingService,FileService,HealthCheckService,JettyService,LoggingService,ManagementService,MetricCollectingService,ObservationService,PrometheusExpositionService,RedirectService,ResteasyService,SimpleDecoratingHttpService,SimpleDecoratingRpcService,SimpleDecoratingService,ThriftCallService,ThrottlingRpcService,ThrottlingService,THttpService,TomcatService,WebSocketService
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface Service<I extends Request,O extends Response>
extends Unwrappable
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> TUnwraps thisServiceinto the object of the specifiedtype.serve(ServiceRequestContext ctx, I req) Serves an incomingRequest.default voidInvoked when this service has been added to aServerwith the specified configuration.default booleanshouldCachePath(String path, @Nullable String query, Route route) Returns whether the givenpathandqueryshould be cached if the service's result is successful.unwrap()Unwraps thisServiceand returns the object being decorated.Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
Method Details
-
serviceAdded
Invoked when this service has been added to aServerwith the specified configuration. Please note that this method can be invoked more than once if this service has been added more than once.- Throws:
Exception
-
serve
Serves an incomingRequest. -
as
Unwraps thisServiceinto the object of the specifiedtype. Use this method instead of an explicit downcast. For example:HttpService s = new MyService().decorate(LoggingService.newDecorator()) .decorate(AuthService.newDecorator()); MyService s1 = s.as(MyService.class); LoggingService s2 = s.as(LoggingService.class); AuthService s3 = s.as(AuthService.class);- Specified by:
asin interfaceUnwrappable- Parameters:
type- the type of the object to return- Returns:
- the object of the specified
typeif found, ornullif not found. - See Also:
-
unwrap
Unwraps thisServiceand returns the object being decorated. If thisServiceis the innermost object, this method returns itself. For example:HttpService service1 = new MyService(); assert service1.unwrap() == service1; HttpService service2 = service1.decorate(LoggingService.newDecorator()); HttpService service3 = service2.decorate(AuthService.newDecorator()); assert service2.unwrap() == service1; assert service3.unwrap() == service2; assert service3.unwrap().unwrap() == service1;- Specified by:
unwrapin interfaceUnwrappable
-
shouldCachePath
Returns whether the givenpathandqueryshould be cached if the service's result is successful. By default, exact path mappings with no input query are cached.
-