Interface WebServer<A extends ExchangeContext>
- Type Parameters:
A- the exchange context type
- All Superinterfaces:
BaseWebRouter,ErrorWebRouteInterceptor<A>,ErrorWebRouter<A>,WebRouteInterceptor<A>,WebRouter<A>
- All Known Subinterfaces:
WebServer.Intercepted<A>
The Web server intercepts routes exchanges to matching handlers.
It must be initialized using the WebServer.Boot by providing an ExchangeContext factory which creates the context attached to any exchange and used during its processing.
It is the entry point for configuring the Web routes used to route Web exchanges to a matching Web exchange handlers and the error Web routes used to route error Web exchanges to a matching error Web exchange handlers.
Web routes and error Web routes interceptors are defined in trees of WebServer.Intercepted which are created by defining successive route interceptors which returns intercepted Web server
containing the successive interceptor definitions. In order to be intercepted, a Web route or an error Web route must be specified on such intercepted Web server. This allows to isolate interceptor
and route definitions which is particularly appreciated when defining them in multiple modules.
- Since:
- 1.12
- Author:
- Jeremy Kuhn
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInitializes the Web server in order to be able to specify context aware interceptors and routes.static interfaceWebServer.Configurer<A extends ExchangeContext>A configurer used to configure a Web server.static interfaceWebServer.Intercepted<A extends ExchangeContext>An intercepted Web server applies interceptors when defining Web routes or error Web routes when their criteria are matching interceptor definitions. -
Method Summary
Modifier and TypeMethodDescriptionconfigure(WebServer.Configurer<? super A> configurer) Configures the Web server.configure(List<WebServer.Configurer<? super A>> configurers) Configures the Web server.configureErrorInterceptors(ErrorWebRouteInterceptor.Configurer<? super A> configurer) Configures multiple error Web route interceptors.configureErrorInterceptors(List<ErrorWebRouteInterceptor.Configurer<? super A>> configurers) Configures multiple error Web route interceptors.configureErrorRoutes(ErrorWebRouter.Configurer<? super A> configurer) Configures multiple error Web routes and returns the originating error Web router.configureErrorRoutes(List<ErrorWebRouter.Configurer<? super A>> configurers) Configures multiple error Web routes and returns the originating error Web router.configureInterceptors(WebRouteInterceptor.Configurer<? super A> configurer) Configures multiple Web route interceptors.configureInterceptors(List<WebRouteInterceptor.Configurer<? super A>> configurers) Configures multiple Web route interceptors.configureRoutes(WebRouter.Configurer<? super A> configurer) Configures multiple Web routes or WebSocket routes and returns the originating Web router.configureRoutes(List<WebRouter.Configurer<? super A>> configurers) Configures multiple Web routes or WebSocket routes and returns the originating Web router.Returns the error Web routes defined in the router.Returns the Web routes defined in the router.Returns the WebSocket routes defined in the router.Returns a new interceptor manager for defining a Web route interceptor.default WebServer.Intercepted<A> intercept(Function<WebRouteInterceptorManager<A, ? extends WebRouteInterceptor<A>>, ? extends WebRouteInterceptor<A>> configurer) Configures a Web route interceptor.Returns a new interceptor manager for defining an error Web route interceptor.default WebServer.Intercepted<A> interceptError(Function<ErrorWebRouteInterceptorManager<A, ? extends ErrorWebRouteInterceptor<A>>, ? extends ErrorWebRouteInterceptor<A>> configurer) Configures an error Web route interceptor.WebRouteManager<A, ? extends WebServer<A>> route()Returns a new route manager for defining a Web route.Configures a Web route and returns the originating Web router.ErrorWebRouteManager<A, ? extends WebServer<A>> Returns a new route manager for defining an error Web route.routeError(Consumer<ErrorWebRouteManager<A, ? extends ErrorWebRouter<A>>> configurer) Configures an error Web route and returns the originating error Web router.WebSocketRouteManager<A, ? extends WebServer<A>> Returns a new route manager for defining a WebSocket route.webSocketRoute(Consumer<WebSocketRouteManager<A, ? extends WebRouter<A>>> configurer) Configures a WebSocket route and returns the originating Web router.
-
Method Details
-
getRoutes
Description copied from interface:WebRouterReturns the Web routes defined in the router.
- Specified by:
getRoutesin interfaceWebRouter<A extends ExchangeContext>- Returns:
- a set of Web routes
-
getWebSocketRoutes
Set<WebSocketRoute<A>> getWebSocketRoutes()Description copied from interface:WebRouterReturns the WebSocket routes defined in the router.
- Specified by:
getWebSocketRoutesin interfaceWebRouter<A extends ExchangeContext>- Returns:
- a set of WebSocket routes
-
intercept
WebRouteInterceptorManager<A,WebServer.Intercepted<A>> intercept()Description copied from interface:WebRouteInterceptorReturns a new interceptor manager for defining a Web route interceptor.
- Specified by:
interceptin interfaceWebRouteInterceptor<A extends ExchangeContext>- Returns:
- a new Web route interceptor manager
-
intercept
default WebServer.Intercepted<A> intercept(Function<WebRouteInterceptorManager<A, ? extends WebRouteInterceptor<A>>, ? extends WebRouteInterceptor<A>> configurer) Description copied from interface:WebRouteInterceptorConfigures a Web route interceptor.
The result returned by the specified configurer function must be the Web route interceptor returned by the input interceptor manager after defining the interceptor and which contains the configured interceptor. If that requirement is not met, invoking this method will most likely result in a no-op operation since no route could be defined on a Web route interceptor containing the configured interceptor.
- Specified by:
interceptin interfaceWebRouteInterceptor<A extends ExchangeContext>- Parameters:
configurer- a Web route interceptor configurer function- Returns:
- the Web route interceptor containing the configured interceptor
-
route
WebRouteManager<A,? extends WebServer<A>> route()Description copied from interface:WebRouterReturns a new route manager for defining a Web route.
- Specified by:
routein interfaceWebRouter<A extends ExchangeContext>- Returns:
- a new Web route manager
-
route
Description copied from interface:WebRouterConfigures a Web route and returns the originating Web router.
- Specified by:
routein interfaceWebRouter<A extends ExchangeContext>- Parameters:
configurer- a Web route configurer function- Returns:
- the originating Web router
-
webSocketRoute
WebSocketRouteManager<A,? extends WebServer<A>> webSocketRoute()Description copied from interface:WebRouterReturns a new route manager for defining a WebSocket route.
- Specified by:
webSocketRoutein interfaceWebRouter<A extends ExchangeContext>- Returns:
- a new WebSocket route manager
-
webSocketRoute
default WebServer<A> webSocketRoute(Consumer<WebSocketRouteManager<A, ? extends WebRouter<A>>> configurer) Description copied from interface:WebRouterConfigures a WebSocket route and returns the originating Web router.
- Specified by:
webSocketRoutein interfaceWebRouter<A extends ExchangeContext>- Parameters:
configurer- a WebSocket route configurer function- Returns:
- the originating Web router
-
configureInterceptors
WebServer.Intercepted<A> configureInterceptors(WebRouteInterceptor.Configurer<? super A> configurer) Description copied from interface:WebRouteInterceptorConfigures multiple Web route interceptors.
- Specified by:
configureInterceptorsin interfaceWebRouteInterceptor<A extends ExchangeContext>- Parameters:
configurer- a Web route interceptor configurer- Returns:
- the Web route interceptor containing the configured interceptors
-
configureInterceptors
WebServer.Intercepted<A> configureInterceptors(List<WebRouteInterceptor.Configurer<? super A>> configurers) Description copied from interface:WebRouteInterceptorConfigures multiple Web route interceptors.
- Specified by:
configureInterceptorsin interfaceWebRouteInterceptor<A extends ExchangeContext>- Parameters:
configurers- a list of Web route interceptor configurers- Returns:
- the Web route interceptor containing the configured interceptors
-
configureRoutes
Description copied from interface:WebRouterConfigures multiple Web routes or WebSocket routes and returns the originating Web router.
- Specified by:
configureRoutesin interfaceWebRouter<A extends ExchangeContext>- Parameters:
configurer- a Web route configurer- Returns:
- the originating Web router
-
configureRoutes
Description copied from interface:WebRouterConfigures multiple Web routes or WebSocket routes and returns the originating Web router.
- Specified by:
configureRoutesin interfaceWebRouter<A extends ExchangeContext>- Parameters:
configurers- a list of Web route configurers- Returns:
- the originating Web router
-
getErrorRoutes
Set<ErrorWebRoute<A>> getErrorRoutes()Description copied from interface:ErrorWebRouterReturns the error Web routes defined in the router.
- Specified by:
getErrorRoutesin interfaceErrorWebRouter<A extends ExchangeContext>- Returns:
- a set of error Web routes
-
interceptError
ErrorWebRouteInterceptorManager<A,WebServer.Intercepted<A>> interceptError()Description copied from interface:ErrorWebRouteInterceptorReturns a new interceptor manager for defining an error Web route interceptor.
- Specified by:
interceptErrorin interfaceErrorWebRouteInterceptor<A extends ExchangeContext>- Returns:
- a new error Web route interceptor manager
-
interceptError
default WebServer.Intercepted<A> interceptError(Function<ErrorWebRouteInterceptorManager<A, ? extends ErrorWebRouteInterceptor<A>>, ? extends ErrorWebRouteInterceptor<A>> configurer) Description copied from interface:ErrorWebRouteInterceptorConfigures an error Web route interceptor.
The result returned by the specified configurer function must be the error Web route interceptor returned by the input interceptor manager after defining the interceptor and which contains the configured interceptor. If that requirement is not met, invoking this method will most likely result in a no-op operation since no route could be defined on an error Web route interceptor containing the configured interceptor.
- Specified by:
interceptErrorin interfaceErrorWebRouteInterceptor<A extends ExchangeContext>- Parameters:
configurer- an error Web route interceptor configurer function- Returns:
- the error Web route interceptor containing the configured interceptor
-
routeError
ErrorWebRouteManager<A,? extends WebServer<A>> routeError()Description copied from interface:ErrorWebRouterReturns a new route manager for defining an error Web route.
- Specified by:
routeErrorin interfaceErrorWebRouter<A extends ExchangeContext>- Returns:
- a new error Web route manager
-
routeError
default WebServer<A> routeError(Consumer<ErrorWebRouteManager<A, ? extends ErrorWebRouter<A>>> configurer) Description copied from interface:ErrorWebRouterConfigures an error Web route and returns the originating error Web router.
- Specified by:
routeErrorin interfaceErrorWebRouter<A extends ExchangeContext>- Parameters:
configurer- an error Web route configurer function- Returns:
- the originating error Web router
-
configureErrorInterceptors
WebServer.Intercepted<A> configureErrorInterceptors(ErrorWebRouteInterceptor.Configurer<? super A> configurer) Description copied from interface:ErrorWebRouteInterceptorConfigures multiple error Web route interceptors.
- Specified by:
configureErrorInterceptorsin interfaceErrorWebRouteInterceptor<A extends ExchangeContext>- Parameters:
configurer- an error Web route interceptor configurer- Returns:
- the error Web route interceptor containing the configured interceptors
-
configureErrorInterceptors
WebServer.Intercepted<A> configureErrorInterceptors(List<ErrorWebRouteInterceptor.Configurer<? super A>> configurers) Description copied from interface:ErrorWebRouteInterceptorConfigures multiple error Web route interceptors.
- Specified by:
configureErrorInterceptorsin interfaceErrorWebRouteInterceptor<A extends ExchangeContext>- Parameters:
configurers- a list of error Web route interceptor configurers- Returns:
- the error Web route interceptor containing the configured interceptors
-
configureErrorRoutes
Description copied from interface:ErrorWebRouterConfigures multiple error Web routes and returns the originating error Web router.
- Specified by:
configureErrorRoutesin interfaceErrorWebRouter<A extends ExchangeContext>- Parameters:
configurer- an error Web route configurer- Returns:
- the originating error Web router
-
configureErrorRoutes
Description copied from interface:ErrorWebRouterConfigures multiple error Web routes and returns the originating error Web router.
- Specified by:
configureErrorRoutesin interfaceErrorWebRouter<A extends ExchangeContext>- Parameters:
configurers- a list of error Web route configurers- Returns:
- the originating error Web router
-
configure
Configures the Web server.
The resulting Web server can be the originating Web server or an intercepted Web server depending on whether interceptors are defined in the configurer and the intercepted Web server thus obtained is returned by the configurer.
- Parameters:
configurer- A Web server configurer- Returns:
- a Web server
-
configure
Configures the Web server.
The resulting Web server can be the originating Web server or an intercepted Web server depending on whether interceptors are defined in the configurers and the intercepted Web server thus obtained is returned by the last configurer.
- Parameters:
configurers- A Web server configurer- Returns:
- a Web server
-