Interface Middleware<I,O>

Type Parameters:
I - The input type
O - The output type
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 Middleware<I,O>
Middleware is a function that wraps action execution, allowing pre-processing and post-processing of requests and responses.

Middleware functions receive the request, action context, and a "next" function to call the next middleware in the chain (or the actual action if at the end of the chain).

Example usage:

 
 Middleware<String, String> loggingMiddleware = (request, context, next) -> {
 	System.out.println("Before: " + request);
 	String result = next.apply(request, context);
 	System.out.println("After: " + result);
 	return result;
 };
 
 
  • Method Summary

    Modifier and Type
    Method
    Description
    handle(I request, ActionContext context, MiddlewareNext<I,O> next)
    Processes the request through this middleware.
  • Method Details

    • handle

      O handle(I request, ActionContext context, MiddlewareNext<I,O> next) throws GenkitException
      Processes the request through this middleware.
      Parameters:
      request - the input request
      context - the action context
      next - the next function in the middleware chain
      Returns:
      the output response
      Throws:
      GenkitException - if processing fails