Add methods to prepend WebFilter + WebExceptionHandler

This commit is contained in:
Rossen Stoyanchev 2017-03-10 10:57:31 -05:00
parent 2cd6240dab
commit 1c9d4deba2
1 changed files with 22 additions and 2 deletions

View File

@ -131,7 +131,7 @@ public class WebHttpHandlerBuilder {
/** /**
* Add the given filters to use for processing requests. * Add the given filters.
* @param filters the filters to add * @param filters the filters to add
*/ */
public WebHttpHandlerBuilder filters(List<? extends WebFilter> filters) { public WebHttpHandlerBuilder filters(List<? extends WebFilter> filters) {
@ -142,7 +142,17 @@ public class WebHttpHandlerBuilder {
} }
/** /**
* Add the given exception handler to apply at the end of request processing. * Insert the given filter before other configured filters.
* @param filter the filters to insert
*/
public WebHttpHandlerBuilder prependFilter(WebFilter filter) {
Assert.notNull(filter, "WebFilter is required");
this.filters.add(0, filter);
return this;
}
/**
* Add the given exception handlers.
* @param handlers the exception handlers * @param handlers the exception handlers
*/ */
public WebHttpHandlerBuilder exceptionHandlers(List<WebExceptionHandler> handlers) { public WebHttpHandlerBuilder exceptionHandlers(List<WebExceptionHandler> handlers) {
@ -152,6 +162,16 @@ public class WebHttpHandlerBuilder {
return this; return this;
} }
/**
* Insert the given exception handler before other configured handlers.
* @param handler the exception handler to insert
*/
public WebHttpHandlerBuilder prependExceptionHandler(WebExceptionHandler handler) {
Assert.notNull(handler, "WebExceptionHandler is required");
this.exceptionHandlers.add(0, handler);
return this;
}
/** /**
* Configure the {@link WebSessionManager} to set on the * Configure the {@link WebSessionManager} to set on the
* {@link ServerWebExchange WebServerExchange}. * {@link ServerWebExchange WebServerExchange}.