- Enclosing interface:
WebServer<A extends ExchangeContext>
Initializes the Web server in order to be able to specify context aware interceptors and routes.
A Web server is responsible for creating the ExchangeContext
for each requests and route them to the right exchange handler and, in case of error, route the error Web exchange to the right
error Web exchange handler. The boot Web server must be used on startup to provide the exchange context factory that will be used to create the context on each request.
The resulting WebServer
is then used to define the interceptors, routes, error interceptors and error routes.
- Since:
- 1.12
- Author:
- Jeremy Kuhn
-
Method Summary
Modifier and TypeMethodDescriptiondefault WebServer
<ExchangeContext> Initializes the Web server with an empty context factory (i.e. supplyingnull
).<T extends ExchangeContext>
WebServer<T> Initializes the Web server with the specified context factory.
-
Method Details
-
webServer
Initializes the Web server with an empty context factory (i.e. supplying
null
).Applications which do not rely on the exchange context to serve requests can be initialized that way.
- Returns:
- the initialized Web server
- Throws:
IllegalStateException
- if the Web server has already been initialized
-
webServer
<T extends ExchangeContext> WebServer<T> webServer(Supplier<T> contextFactory) throws IllegalStateException Initializes the Web server with the specified context factory.
The context type is unique for all interceptors and routes defined subsequently on the server as a result the usage of polymorphism and interfaces should be preferred all the way to give a maximum of flexibility.
- Type Parameters:
T
- the context type, ideally an interface- Parameters:
contextFactory
- the context factory- Returns:
- the initialized Web server
- Throws:
IllegalStateException
- if the Web server has already been initialized
-