Class PathFilterMiddleware
- java.lang.Object
-
- com.github.fmjsjx.libnetty.http.server.middleware.PathFilterMiddleware
-
- All Implemented Interfaces:
Middleware,java.util.function.BiFunction<HttpRequestContext,MiddlewareChain,java.util.concurrent.CompletionStage<HttpResult>>
public class PathFilterMiddleware extends java.lang.Object implements Middleware
Delegating aMiddlewarewith a path filter.The delegated
Middlewareonly effective when the path filter returnstrue.- Since:
- 1.1
-
-
Constructor Summary
Constructors Constructor Description PathFilterMiddleware(java.util.function.Predicate<java.lang.String> pathFilter, Middleware delegated)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletionStage<HttpResult>apply(HttpRequestContext ctx, MiddlewareChain next)Apply thisMiddlewareto the givenHttpRequestContext.static java.util.function.Predicate<java.lang.String>toFilter(java.lang.String... pathPrefixes)Convert path prefixes to path filter.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.fmjsjx.libnetty.http.server.middleware.Middleware
close, onServerClosed
-
-
-
-
Constructor Detail
-
PathFilterMiddleware
public PathFilterMiddleware(java.util.function.Predicate<java.lang.String> pathFilter, Middleware delegated)- Parameters:
pathFilter- aPredicatefilters the HTTP pathdelegated- the delegatedMiddleware
-
-
Method Detail
-
toFilter
public static final java.util.function.Predicate<java.lang.String> toFilter(java.lang.String... pathPrefixes)
Convert path prefixes to path filter.- Parameters:
pathPrefixes- the prefixes of HTTP paths- Returns:
- a
Predicate<String>
-
apply
public java.util.concurrent.CompletionStage<HttpResult> apply(HttpRequestContext ctx, MiddlewareChain next)
Description copied from interface:MiddlewareApply thisMiddlewareto the givenHttpRequestContext.- Specified by:
applyin interfacejava.util.function.BiFunction<HttpRequestContext,MiddlewareChain,java.util.concurrent.CompletionStage<HttpResult>>- Specified by:
applyin interfaceMiddleware- Parameters:
ctx- theHttpRequestContextobject of the current HTTP requestnext- theMiddlewareChainfor invoking the nextMiddleware- Returns:
- a
CompletionStage<HttpResult>
-
-