Middleware<CTX extends Context> typedef

Middleware<CTX extends Context> = FutureOr<void> Function(CTX ctx, NextFunction next)

Middleware function signature.

A middleware function receives the current context and a next function. It can perform operations before calling next(), after calling next(), or both (wrapping the next call).

Example:

// Logging middleware
Middleware<Context> loggingMiddleware = (ctx, next) async {
  print('Processing update ${ctx.update.updateId}');
  await next(); // Continue to next middleware
  print('Finished processing update ${ctx.update.updateId}');
};

Implementation

typedef Middleware<CTX extends Context> = FutureOr<void> Function(
  CTX ctx,
  NextFunction next,
);