UseMiddleware class

Applies middleware to a controller or endpoint.

Middleware can be used to intercept and process requests and responses before they reach the controller or after they leave it. Common use cases include logging, authentication, and request transformation.

Example:

@Controller('/api/users')
@UseMiddleware([LoggingMiddleware])
class UserController {
  // All endpoints in this controller will use LoggingMiddleware

  @Get('/')
  Future<Response> getAllUsers(Request request) { ... }

  @Post('/')
  @UseMiddleware([ValidationMiddleware])
  // This endpoint will use both LoggingMiddleware and ValidationMiddleware
  Future<Response> createUser(Request request) { ... }
}

Constructors

UseMiddleware.new(List<Type> middlewares)
Creates a UseMiddleware annotation with the specified middleware types.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
middlewares List<Type>
The list of middleware types to apply.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited