Module io.avaje.jex

Interface HttpFilter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface HttpFilter
A filter used to pre/post-process incoming requests. Pre-processing occurs before the application's exchange handler is invoked, and post-processing occurs after the exchange handler returns. Filters are organized in chains, and are associated with Context instances.

Each HttpFilter in the chain, invokes the next filter within its own filter(Context, FilterChain) implementation. The final HttpFilter in the chain invokes the applications exchange handler.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Filter chain that contains all subsequent filters that are configured, as well as the final route.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Asks this filter to pre/post-process the given request.
  • Method Details

    • filter

      void filter(Context ctx, HttpFilter.FilterChain chain)
      Asks this filter to pre/post-process the given request. The filter can:
      • Examine or modify the request headers.
      • Set attribute objects in the context, which other filters or the handler can access.
      • Decide to either:
        1. Invoke the next filter in the chain, by calling HttpFilter.FilterChain.proceed().
        2. Terminate the chain of invocation, by not calling HttpFilter.FilterChain.proceed().
      • If option 1. above is taken, then when filter() returns all subsequent filters in the Chain have been called, and the response headers can be examined or modified.
      • If option 2. above is taken, then this Filter must use the Context to send back an appropriate response.
      Parameters:
      ctx - the Context of the current request
      chain - the FilterChain which allows the next filter to be invoked