Uses of Interface
com.google.genkit.core.middleware.Middleware
Packages that use Middleware
Package
Description
Middleware support for Genkit Java.
-
Uses of Middleware in com.google.genkit
Method parameters in com.google.genkit with type arguments of type MiddlewareModifier and TypeMethodDescriptionGenkit.defineFlow(String name, Class<I> inputClass, Class<O> outputClass, BiFunction<ActionContext, I, O> handler, List<Middleware<I, O>> middleware) Defines a flow with middleware.Genkit.defineFlow(String name, Class<I> inputClass, Class<O> outputClass, Function<I, O> handler, List<Middleware<I, O>> middleware) Defines a flow with a simple handler and middleware. -
Uses of Middleware in com.google.genkit.core
Methods in com.google.genkit.core with parameters of type MiddlewareModifier and TypeMethodDescriptionFlow.withMiddleware(Middleware<I, O> middleware) Creates a copy of this flow with additional middleware.Method parameters in com.google.genkit.core with type arguments of type MiddlewareModifier and TypeMethodDescriptionFlow.define(Registry registry, String name, Class<I> inputClass, Class<O> outputClass, BiFunction<ActionContext, I, O> fn, List<Middleware<I, O>> middleware) Defines a new non-streaming flow with middleware and registers it.Flow.withMiddleware(List<Middleware<I, O>> middlewareList) Creates a copy of this flow with additional middleware. -
Uses of Middleware in com.google.genkit.core.middleware
Methods in com.google.genkit.core.middleware that return MiddlewareModifier and TypeMethodDescriptionstatic <I,O> Middleware <I, O> CommonMiddleware.beforeAfter(BiConsumer<I, ActionContext> before, BiConsumer<O, ActionContext> after) Creates a before/after middleware that runs callbacks before and after execution.static <I,O> Middleware <I, O> CommonMiddleware.cache(MiddlewareCache<O> cache, Function<I, String> keyExtractor) Creates a caching middleware that caches results based on a key.static <I,O> Middleware <I, O> CommonMiddleware.conditional(BiPredicate<I, ActionContext> predicate, Middleware<I, O> middleware) Creates a conditional middleware that only applies if the predicate is true.static <I,O> Middleware <I, O> CommonMiddleware.errorHandler(Function<GenkitException, O> errorHandler) Creates an error handling middleware that catches and transforms exceptions.static <I,O> Middleware <I, O> Creates a logging middleware that logs requests and responses.static <I,O> Middleware <I, O> Creates a logging middleware with a custom logger.static <I,O> Middleware <I, O> CommonMiddleware.rateLimit(int maxRequests, long windowMs) Creates a rate limiting middleware (simple token bucket implementation).static <I,O> Middleware <I, O> CommonMiddleware.retry(int maxRetries, long initialDelayMs) Creates a retry middleware with exponential backoff.static <I,O> Middleware <I, O> CommonMiddleware.retry(int maxRetries, long initialDelayMs, Function<GenkitException, Boolean> shouldRetry) Creates a retry middleware with exponential backoff and custom retry predicate.static <I,O> Middleware <I, O> CommonMiddleware.timeout(long timeoutMs) Creates a timeout middleware that throws an exception if execution takes too long.static <I,O> Middleware <I, O> Creates a timing middleware that measures execution time.static <I,O> Middleware <I, O> CommonMiddleware.transformRequest(Function<I, I> transformer) Creates a transformation middleware that transforms the request before processing.static <I,O> Middleware <I, O> CommonMiddleware.transformResponse(Function<O, O> transformer) Creates a transformation middleware that transforms the response after processing.static <I,O> Middleware <I, O> Creates a validation middleware that validates the request before processing.Methods in com.google.genkit.core.middleware that return types with arguments of type MiddlewareModifier and TypeMethodDescriptionList<Middleware<I, O>> MiddlewareChain.getMiddlewareList()Returns an unmodifiable view of the middleware list.Methods in com.google.genkit.core.middleware with parameters of type MiddlewareModifier and TypeMethodDescriptionstatic <I,O> Middleware <I, O> CommonMiddleware.conditional(BiPredicate<I, ActionContext> predicate, Middleware<I, O> middleware) Creates a conditional middleware that only applies if the predicate is true.static <I,O> MiddlewareChain <I, O> MiddlewareChain.of(Middleware<I, O>... middleware) Creates a new MiddlewareChain with the specified middleware.MiddlewareChain.use(Middleware<I, O> middleware) Adds a middleware to the chain.MiddlewareChain.useFirst(Middleware<I, O> middleware) Inserts a middleware at the beginning of the chain.Method parameters in com.google.genkit.core.middleware with type arguments of type MiddlewareModifier and TypeMethodDescriptionMiddlewareChain.useAll(List<Middleware<I, O>> middlewareList) Adds multiple middleware to the chain.Constructor parameters in com.google.genkit.core.middleware with type arguments of type MiddlewareModifierConstructorDescriptionMiddlewareChain(List<Middleware<I, O>> middlewareList) Creates a new MiddlewareChain with the given middleware.