io.micronaut.http.filter.ServerFilterChain Java Examples
The following examples show how to use
io.micronaut.http.filter.ServerFilterChain.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MicronautLambdaContainerHandler.java From micronaut-aws with Apache License 2.0 | 4 votes |
private Publisher<MutableHttpResponse<?>> filterPublisher( AtomicReference<HttpRequest<?>> requestReference, Publisher<? extends MutableHttpResponse<?>> routePublisher) { Publisher<? extends io.micronaut.http.MutableHttpResponse<?>> finalPublisher; List<HttpFilter> filters = new ArrayList<>(lambdaContainerEnvironment.getRouter().findFilters(requestReference.get())); if (!filters.isEmpty()) { // make the action executor the last filter in the chain filters.add((HttpServerFilter) (req, chain) -> (Publisher<MutableHttpResponse<?>>) routePublisher); AtomicInteger integer = new AtomicInteger(); int len = filters.size(); ServerFilterChain filterChain = new LambdaFilterChain(integer, len, filters, requestReference); HttpFilter httpFilter = filters.get(0); Publisher<? extends HttpResponse<?>> resultingPublisher = httpFilter.doFilter(requestReference.get(), filterChain); finalPublisher = (Publisher<MutableHttpResponse<?>>) resultingPublisher; } else { finalPublisher = routePublisher; } return (Publisher<MutableHttpResponse<?>>) finalPublisher; }
Example #2
Source File: AuthFilter.java From kyoko with MIT License | 4 votes |
@Override public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain) { var auth = request.getHeaders().findFirst("authorization"); return sessionManager.authorizeToken(auth) .doOnError(err -> logger.error("Auth error", err)) .onErrorComplete() .toSingle(Session.EMPTY_SESSION) .flatMap(Session::updateSession) .flatMap(sessionManager::updateSession) .flatMap(session -> session == Session.EMPTY_SESSION ? Single.just(ErrorResponse.get(ErrorCode.UNAUTHORIZED)) : Single.fromPublisher(chain.proceed(request.setAttribute("session", session)))) .toFlowable(); }
Example #3
Source File: RateLimitFilter.java From kyoko with MIT License | 3 votes |
@Override public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain) { return null; }