MethodRouter class final

The handlers registered for one path, keyed by method.

Built with the verb functions in this library and chained the way axum chains get(list).post(create):

final notes = Router.prefixed('/notes')
  ..route('/', get(listNotes).post(writeNote, status: 201))
  ..route('/{id}', get(readNote).delete(removeNote));

An endpoint returns a value and the verb builder turns it into a response: a model becomes JSON through its serialize, null becomes 204, a Rejection becomes its own status, and anything thrown that is not a rejection becomes an opaque 500 with the real error going to the router's onError. Nothing in an endpoint builds a response or catches an error.

Constructors

MethodRouter()
Starts an empty set.
const

Properties

handlers Map<String, Handler>
The handlers registered so far, keyed by uppercase method.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

any<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds an endpoint for every method no other handler claims.
connect<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds a CONNECT endpoint.
delete<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds a DELETE endpoint.
get<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds a GET endpoint.
Adds a HEAD endpoint.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
on<T>(String method, Endpoint<T> endpoint, {int status = 200}) MethodRouter
Returns a set with endpoint added for method.
options<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds an OPTIONS endpoint.
patch<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds a PATCH endpoint.
post<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds a POST endpoint.
put<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds a PUT endpoint.
toString() String
A string representation of this object.
inherited
trace<T>(Endpoint<T> endpoint, {int status = 200}) MethodRouter
Adds a TRACE endpoint.

Operators

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