public abstract class HttpHandlerAdapterSupport
extends java.lang.Object
HttpHandler
contract.
Provides support for delegating incoming requests to a single or multiple
HttpHandler
s each mapped to a distinct context path. In either case
sub-classes simply use getHttpHandler()
to access the handler to
delegate incoming requests to.
Modifier and Type | Class and Description |
---|---|
private static class |
HttpHandlerAdapterSupport.CompositeHttpHandler
Composite HttpHandler that selects the handler to use by context path.
|
Modifier and Type | Field and Description |
---|---|
private HttpHandler |
httpHandler |
protected Log |
logger |
Constructor and Description |
---|
HttpHandlerAdapterSupport(HttpHandler httpHandler)
Constructor with a single
HttpHandler to use for all requests. |
HttpHandlerAdapterSupport(java.util.Map<java.lang.String,HttpHandler> handlerMap)
Constructor with
HttpHandler s mapped to distinct context paths. |
Modifier and Type | Method and Description |
---|---|
HttpHandler |
getHttpHandler()
Return the
HttpHandler to delegate incoming requests to. |
protected final Log logger
private final HttpHandler httpHandler
public HttpHandlerAdapterSupport(HttpHandler httpHandler)
HttpHandler
to use for all requests.httpHandler
- the handler to usepublic HttpHandlerAdapterSupport(java.util.Map<java.lang.String,HttpHandler> handlerMap)
HttpHandler
s mapped to distinct context paths.
Context paths must start but not end with "/" and must be encoded.
At request time context paths are compared against the "raw" path of the request URI in the order in which they are provided. The first one to match is chosen. If none match the response status is set to 404.
handlerMap
- map with context paths and HttpHandler
s.ServerHttpRequest.getContextPath()
public HttpHandler getHttpHandler()
HttpHandler
to delegate incoming requests to.