IDoxTerminableMiddleware class abstract
A middleware that runs code after the answer is sent to the client,
like the terminate of Laravel. Good for work the client should not
wait for: logs, metrics, cleanup.
terminate gets the request and the answer that was sent.
res.status is the status that was sent. An error in terminate is
sent to ExceptionHandler.report. It never changes the answer.
A class can also implement IDoxMiddleware or IDoxNextMiddleware,
to run code before the controller too.
class Metrics implements IDoxMiddleware, IDoxTerminableMiddleware {
@override
dynamic handle(IDoxRequest req) => req;
@override
void terminate(DoxRequest req, DoxResponse res) {
print('${req.method} ${req.uri.path} ${res.status}');
}
}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
terminate(
DoxRequest req, DoxResponse res) → FutureOr< void> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited