UseGuards class
Applies guards to a controller or endpoint.
Guards are special middleware that can prevent a request from being processed based on certain conditions. They are commonly used for authentication and authorization.
Example:
@Controller('/api/admin')
@UseGuards([AuthGuard, AdminGuard])
class AdminController {
// All endpoints in this controller will be protected by AuthGuard and AdminGuard
@Get('/stats')
Future<Response> getStats(Request request) { ... }
@Post('/settings')
@UseGuards([SuperAdminGuard])
// This endpoint will use AuthGuard, AdminGuard, and SuperAdminGuard
Future<Response> updateSettings(Request request) { ... }
}
Constructors
-
UseGuards.new(List<
Type> guards) -
Creates a UseGuards annotation with the specified guard types.
const
Properties
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