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
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
CONNECTendpoint. -
delete<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds a
DELETEendpoint. -
get<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds a
GETendpoint. -
head<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds a
HEADendpoint. -
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
endpointadded formethod. -
options<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds an
OPTIONSendpoint. -
patch<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds a
PATCHendpoint. -
post<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds a
POSTendpoint. -
put<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds a
PUTendpoint. -
toString(
) → String -
A string representation of this object.
inherited
-
trace<
T> (Endpoint< T> endpoint, {int status = 200}) → MethodRouter -
Adds a
TRACEendpoint.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited