Class HttpWebHandlerAdapter
- java.lang.Object
- org.springframework.web.server.handler.WebHandlerDecorator
- org.springframework.web.server.adapter.HttpWebHandlerAdapter
- All Implemented Interfaces:
HttpHandler,WebHandler
public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHandler
Default adapter ofWebHandlerto theHttpHandlercontract.By default creates and configures a
DefaultServerWebExchangeand then invokes the targetWebHandler.- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze
Constructor Summary
Constructors Constructor Description HttpWebHandlerAdapter(WebHandler delegate)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()This method must be invoked after all properties have been set to complete initialization.protected ServerWebExchangecreateExchange(ServerHttpRequest request, ServerHttpResponse response)protected StringformatRequest(ServerHttpRequest request)Format the request for logging purposes including HTTP method and URL.ApplicationContextgetApplicationContext()Return the configuredApplicationContext, if any.ServerCodecConfigurergetCodecConfigurer()Return the configuredServerCodecConfigurer.ForwardedHeaderTransformergetForwardedHeaderTransformer()Return the configuredForwardedHeaderTransformer.LocaleContextResolvergetLocaleContextResolver()Return the configuredLocaleContextResolver.WebSessionManagergetSessionManager()Return the configuredWebSessionManager.reactor.core.publisher.Mono<Void>handle(ServerHttpRequest request, ServerHttpResponse response)Handle the given request and write to the response.voidsetApplicationContext(ApplicationContext applicationContext)Configure theApplicationContextassociated with the web application, if it was initialized with one viaWebHttpHandlerBuilder.applicationContext(ApplicationContext).voidsetCodecConfigurer(ServerCodecConfigurer codecConfigurer)Configure a customServerCodecConfigurer.voidsetForwardedHeaderTransformer(ForwardedHeaderTransformer transformer)Enable processing of forwarded headers, either extracting and removing, or remove only.voidsetLocaleContextResolver(LocaleContextResolver resolver)Configure a customLocaleContextResolver.voidsetSessionManager(WebSessionManager sessionManager)Configure a customWebSessionManagerto use for managing web sessions.Methods inherited from class org.springframework.web.server.handler.WebHandlerDecorator
getDelegate, handle, toString
Constructor Detail
HttpWebHandlerAdapter
public HttpWebHandlerAdapter(WebHandler delegate)
Method Detail
setSessionManager
public void setSessionManager(WebSessionManager sessionManager)
Configure a customWebSessionManagerto use for managing web sessions. The provided instance is set on each createdDefaultServerWebExchange.By default this is set to
DefaultWebSessionManager.- Parameters:
sessionManager- the session manager to use
getSessionManager
public WebSessionManager getSessionManager()
Return the configuredWebSessionManager.
setCodecConfigurer
public void setCodecConfigurer(ServerCodecConfigurer codecConfigurer)
Configure a customServerCodecConfigurer. The provided instance is set on each createdDefaultServerWebExchange.By default this is set to
ServerCodecConfigurer.create().- Parameters:
codecConfigurer- the codec configurer to use
getCodecConfigurer
public ServerCodecConfigurer getCodecConfigurer()
Return the configuredServerCodecConfigurer.
setLocaleContextResolver
public void setLocaleContextResolver(LocaleContextResolver resolver)
Configure a customLocaleContextResolver. The provided instance is set on each createdDefaultServerWebExchange.By default this is set to
AcceptHeaderLocaleContextResolver.- Parameters:
resolver- the locale context resolver to use
getLocaleContextResolver
public LocaleContextResolver getLocaleContextResolver()
Return the configuredLocaleContextResolver.
setForwardedHeaderTransformer
public void setForwardedHeaderTransformer(ForwardedHeaderTransformer transformer)
Enable processing of forwarded headers, either extracting and removing, or remove only.By default this is not set.
- Parameters:
transformer- the transformer to use- Since:
- 5.1
getForwardedHeaderTransformer
@Nullable public ForwardedHeaderTransformer getForwardedHeaderTransformer()
Return the configuredForwardedHeaderTransformer.- Since:
- 5.1
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
Configure theApplicationContextassociated with the web application, if it was initialized with one viaWebHttpHandlerBuilder.applicationContext(ApplicationContext).- Parameters:
applicationContext- the context- Since:
- 5.0.3
getApplicationContext
@Nullable public ApplicationContext getApplicationContext()
Return the configuredApplicationContext, if any.- Since:
- 5.0.3
afterPropertiesSet
public void afterPropertiesSet()
This method must be invoked after all properties have been set to complete initialization.
handle
public reactor.core.publisher.Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response)
Description copied from interface:HttpHandlerHandle the given request and write to the response.- Specified by:
handlein interfaceHttpHandler- Parameters:
request- current requestresponse- current response- Returns:
- indicates completion of request handling
createExchange
protected ServerWebExchange createExchange(ServerHttpRequest request, ServerHttpResponse response)
formatRequest
protected String formatRequest(ServerHttpRequest request)
Format the request for logging purposes including HTTP method and URL.By default this prints the HTTP method, the URL path, and the query.
- Parameters:
request- the request to format- Returns:
- the String to display, never empty or
null