Route class

Helps builds a route handler with its interceptors and exception handlers

Constructors

Route(String path, RouteHandler handler, {List<String> methods = const <String>['*'], Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route
factory
Route.delete(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int statusCode = 200, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for DELETE method requests
factory
Route.deleteJson(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor = jsonResponseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for JSON requests with DELETE method
factory
Route.fromInfo(HttpMethod info, RouteHandler handler, {List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Route.get(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for GET method requests
factory
Route.getJson(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor = jsonResponseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for JSON requests with GET method
factory
Route.html(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType = MimeTypes.html, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for HTML requests
factory
Route.json(String path, RouteHandler handler, {List<String> methods = const <String>['GET', 'PUT', 'POST', 'DELETE'], Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor = jsonResponseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for JSON requests
factory
Route.options(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for OPTIONS method requests
factory
Route.patch(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for PATCH method requests
factory
Route.post(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for POST method requests
factory
Route.postJson(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor = jsonResponseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for JSON requests with POST method
factory
Route.put(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for PUT method requests
factory
Route.putJson(String path, RouteHandler handler, {Map<String, String>? pathRegEx, int? statusCode, String? mimeType, String? charset = kDefaultCharset, ResponseProcessor? responseProcessor = jsonResponseProcessor, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException})
Constructs a Route for JSON requests with PUT method
factory

Properties

handler RouteHandler
The route handler function
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
info HttpMethod
final
pathSegments Iterable<String>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

after(RouteInterceptor interceptor, [List<RouteInterceptor>? interceptors]) → void
Add interceptor and optionally interceptors to be executed after handler in the route chain.
before(RouteInterceptor interceptor, [List<RouteInterceptor>? interceptors]) → void
Add interceptor and optionally interceptors to be executed before handler in the route chain.
call(Context ctx) Future<void>
Handles requests
cloneWith({HttpMethod? info, List<RouteInterceptor>? after, List<RouteInterceptor>? before, List<ExceptionHandler>? onException, RouteHandler? handler}) Route
Clones this Route with the new values if provided
getAfter() List<RouteInterceptor>
getBefore() List<RouteInterceptor>
getOnException() List<ExceptionHandler>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onException(ExceptionHandler exceptHandler, [List<ExceptionHandler>? exceptHandlers]) → void
Add exceptHandler and optionally exceptHandlers to be executed after handler in the route chain.
toString() String
Helps while debugging in variables window
override

Operators

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