BaseController class abstract

Base class for all API controllers with common functionality.

Constructors

BaseController.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
router Router
Returns the router for this controller, built automatically from annotations.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

buildRouter() Future<Router>
Builds and caches the router for this controller asynchronously. This method supports JWT middleware integration.
errorResponse(String message, {int statusCode = 500}) Response
Creates an error response.
getAllQueryParams(Request request) Map<String, String>
Extracts all query parameters as a map.
getOptionalHeader(Request request, String name, [String? defaultValue]) String?
Extracts an optional header from the request.
getOptionalParam(Request request, String name) String?
Extracts an optional parameter from the request.
getOptionalQueryParam(Request request, String name, [String? defaultValue]) String?
Extracts an optional query parameter from the request.
getRequiredHeader(Request request, String name) String
Extracts a required header from the request.
getRequiredParam(Request request, String name) String
Extracts a required parameter from the request.
getRequiredQueryParam(Request request, String name) String
Extracts a required query parameter from the request.
jsonResponse(String body, {int statusCode = 200, Map<String, String> additionalHeaders = const {}}) Response
Creates a JSON response with proper headers.
logRequest(Request request, String action) → void
Logs request information.
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