Module io.jooby
Package io.jooby

Interface Route.Filter

All Superinterfaces:
Route.Aware
All Known Subinterfaces:
Route.Before, Route.Decorator
All Known Implementing Classes:
AccessLogHandler, CorsHandler, CsrfHandler, HeadHandler, RateLimitHandler, SSLHandler, TraceHandler, WebVariables
Enclosing class:
Route

public static interface Route.Filter extends Route.Aware
Decorates a route handler by running logic before and after route handler.

 {
   use(next -> ctx -> {
     long start = System.currentTimeMillis();
     Object result = next.apply(ctx);
     long end = System.currentTimeMillis();
     System.out.println("Took: " + (end - start));
     return result;
   });
 }
 
Since:
2.0.0
Author:
edgar
  • Method Details

    • apply

      @NonNull Route.Handler apply(@NonNull Route.Handler next)
      Chain the filter within next handler.
      Parameters:
      next - Next handler.
      Returns:
      A new handler.
    • then

      @NonNull default Route.Filter then(@NonNull Route.Filter next)
      Chain this filter with another and produces a new decorator.
      Parameters:
      next - Next decorator.
      Returns:
      A new decorator.
    • then

      @NonNull default Route.Handler then(@NonNull Route.Handler next)
      Chain this filter with a handler and produces a new handler.
      Parameters:
      next - Next handler.
      Returns:
      A new handler.