Package com.linecorp.armeria.server
Class VirtualHostContextPathServicesBuilder
java.lang.Object
com.linecorp.armeria.server.VirtualHostContextPathServicesBuilder
Builds
ServiceConfig
s for a VirtualHostBuilder
.
All ServiceConfig
s built by this builder will be served under the specified context paths.
Server.builder()
.virtualHost("foo.com")
.contextPath("/v3")
.service(myService) // served by virtual host "foo.com" under "/v3"
-
Method Summary
Modifier and TypeMethodDescriptionand()
Returns the parentAbstractContextPathServicesBuilder
.Returns a new instance ofAbstractContextPathAnnotatedServiceConfigSetters
to build an annotated service fluently.annotatedService
(Object service) Binds the specified annotated service object under the context path.annotatedService
(Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.annotatedService
(Object service, Function<? super HttpService, ? extends HttpService> decorator, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.annotatedService
(String pathPrefix, Object service) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Iterable<?> exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Iterable<?> exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions, Iterable<? extends RequestConverterFunction> requestConverterFunctions, Iterable<? extends ResponseConverterFunction> responseConverterFunctions) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.decorator
(DecoratingHttpServiceFunction decoratingHttpServiceFunction) Decorates allHttpService
s with the specifiedDecoratingHttpServiceFunction
.decorator
(Route route, DecoratingHttpServiceFunction decoratingHttpServiceFunction) decorator
(Route route, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s under the specified directory.decorator
(String pathPattern, DecoratingHttpServiceFunction decoratingHttpServiceFunction) decorator
(String pathPattern, Function<? super HttpService, ? extends HttpService> decorator) decorator
(Function<? super HttpService, ? extends HttpService> decorator) Decorates allHttpService
s with the specifieddecorator
.decoratorUnder
(String prefix, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s under the specified directory.decoratorUnder
(String prefix, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s under the specified directory.route()
Returns aVirtualHostContextPathServiceBindingBuilder
which is for binding anHttpService
fluently.Returns aVirtualHostContextPathDecoratingBindingBuilder
which is for binding adecorator
fluently.service
(HttpServiceWithRoutes serviceWithRoutes, Iterable<? extends Function<? super HttpService, ? extends HttpService>> decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s under the context path.service
(HttpServiceWithRoutes serviceWithRoutes, Function<? super HttpService, ? extends HttpService>... decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s under the context path.service
(Route route, HttpService service) Binds the specifiedHttpService
at the specifiedRoute
under the context path.service
(String pathPattern, HttpService service) Binds the specifiedHttpService
at the specified path pattern under the context path.serviceUnder
(String pathPrefix, HttpService service) Binds the specifiedHttpService
under the specified context path.withRoute
(Consumer<? super VirtualHostContextPathServiceBindingBuilder> customizer) Configures anHttpService
under the context path with thecustomizer
.
-
Method Details
-
withRoute
public VirtualHostContextPathServicesBuilder withRoute(Consumer<? super VirtualHostContextPathServiceBindingBuilder> customizer) Configures anHttpService
under the context path with thecustomizer
. -
route
Returns aVirtualHostContextPathServiceBindingBuilder
which is for binding anHttpService
fluently. -
routeDecorator
Returns aVirtualHostContextPathDecoratingBindingBuilder
which is for binding adecorator
fluently. The specified decorator(s) is/are executed in reverse order of the insertion. -
serviceUnder
Binds the specifiedHttpService
under the specified context path. If the specifiedHttpService
is anHttpServiceWithRoutes
, thepathPrefix
is added to eachRoute
ofServiceWithRoutes.routes()
. For example, theserviceWithRoutes
in the following code will be bound to ("/v1/foo/bar"
) and ("/v1/foo/baz"
):> HttpServiceWithRoutes serviceWithRoutes = new HttpServiceWithRoutes() { > @Override > public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) { ... } > > @Override > public Set<Route> routes() { > return Set.of(Route.builder().path("/bar").build(), > Route.builder().path("/baz").build()); > } > }; > > Server.builder() > .contextPath("/v1") > .serviceUnder("/foo", serviceWithRoutes) > .build();
-
service
Binds the specifiedHttpService
at the specified path pattern under the context path. e.g./login
(no path parameters)/users/{userId}
(curly-brace style)/list/:productType/by/:ordering
(colon style)exact:/foo/bar
(exact match)prefix:/files
(prefix match)glob:/~*/downloads/**
(glob pattern)regex:^/files/(?<filePath>.*)$
(regular expression)
-
service
Binds the specifiedHttpService
at the specifiedRoute
under the context path. -
service
@SafeVarargs public final VirtualHostContextPathServicesBuilder service(HttpServiceWithRoutes serviceWithRoutes, Function<? super HttpService, ? extends HttpService>... decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s under the context path.- Parameters:
serviceWithRoutes
- theHttpServiceWithRoutes
.decorators
- the decorator functions, which will be applied in the order specified.
-
service
public VirtualHostContextPathServicesBuilder service(HttpServiceWithRoutes serviceWithRoutes, Iterable<? extends Function<? super HttpService, ? extends HttpService>> decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s under the context path.- Parameters:
serviceWithRoutes
- theHttpServiceWithRoutes
.decorators
- the decorator functions, which will be applied in the order specified.
-
annotatedService
Binds the specified annotated service object under the context path. -
annotatedService
public VirtualHostContextPathServicesBuilder annotatedService(Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
public VirtualHostContextPathServicesBuilder annotatedService(Object service, Function<? super HttpService, ? extends HttpService> decorator, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
Binds the specified annotated service object under the specified path prefix. -
annotatedService
public VirtualHostContextPathServicesBuilder annotatedService(String pathPrefix, Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
public VirtualHostContextPathServicesBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
,RequestConverterFunction
and/orResponseConverterFunction
-
annotatedService
public VirtualHostContextPathServicesBuilder annotatedService(String pathPrefix, Object service, Iterable<?> exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
public VirtualHostContextPathServicesBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Iterable<?> exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
,RequestConverterFunction
and/orResponseConverterFunction
-
annotatedService
public VirtualHostContextPathServicesBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions, Iterable<? extends RequestConverterFunction> requestConverterFunctions, Iterable<? extends ResponseConverterFunction> responseConverterFunctions) Binds the specified annotated service object under the specified path prefix.- Parameters:
exceptionHandlerFunctions
- theExceptionHandlerFunction
srequestConverterFunctions
- theRequestConverterFunction
sresponseConverterFunctions
- theResponseConverterFunction
s
-
annotatedService
Returns a new instance ofAbstractContextPathAnnotatedServiceConfigSetters
to build an annotated service fluently. -
decorator
public VirtualHostContextPathServicesBuilder decorator(Function<? super HttpService, ? extends HttpService> decorator) Decorates allHttpService
s with the specifieddecorator
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decorator
- theFunction
that decoratesHttpService
s
-
decorator
public VirtualHostContextPathServicesBuilder decorator(DecoratingHttpServiceFunction decoratingHttpServiceFunction) Decorates allHttpService
s with the specifiedDecoratingHttpServiceFunction
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
decorator
public VirtualHostContextPathServicesBuilder decorator(String pathPattern, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s whoseRoute
matches the specifiedpathPattern
. The specified decorator(s) is/are executed in reverse order of the insertion. -
decorator
public VirtualHostContextPathServicesBuilder decorator(String pathPattern, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s whoseRoute
matches the specifiedpathPattern
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
decorator
public VirtualHostContextPathServicesBuilder decorator(Route route, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s under the specified directory. The specified decorator(s) is/are executed in reverse order of the insertion. -
decorator
public VirtualHostContextPathServicesBuilder decorator(Route route, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s whoseRoute
matches the specifiedRoute
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
route
- the route being decorateddecoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
decoratorUnder
public VirtualHostContextPathServicesBuilder decoratorUnder(String prefix, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s under the specified directory. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
decoratorUnder
public VirtualHostContextPathServicesBuilder decoratorUnder(String prefix, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s under the specified directory. The specified decorator(s) is/are executed in reverse order of the insertion. -
and
Returns the parentAbstractContextPathServicesBuilder
.
-