Module io.avaje.jex
Package 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- and 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.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    filter(Context ctx, FilterChain chain)
    Asks this filter to pre/post-process the given request.
  • Method Details

    • filter

      void filter(Context ctx, FilterChain chain) throws IOException
      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 FilterChain.proceed().
        2. Terminate the chain of invocation, by not calling 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
      Throws:
      IOException