MiddlewareContract class abstract
Middleware interface to create custom middleware for http. Extend this class and override the functions that you want to intercept.
Intercepting: You have to implement three functions, interceptRequest
,
interceptResponse
and interceptError
.
Example (Simple logging):
class CustomMiddleWare extends MiddlewareContract {
@override
Function(http.Response) interceptRequest(RequestData data) {
print("${data.method} Url: ${data.url}")
return (response) {
print("POST Status: ${}")
};
}
@override
Function(http.Response) interceptResponse(ResponseData data) {
print("${data.method}: ${response}")
return (response) {
print("POST Status: ${}")
};
}
}
@override
Function(http.Response) interceptError(error) {
print("$err")
}
- Implementers
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
-
interceptError(
dynamic error) → void -
interceptRequest(
RequestData data) → void -
interceptResponse(
ResponseData data) → void -
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