Middleware<R> class

The descendant of this class can be used as a request or response middleware. For the request middleware specify the R generic type as aRestRowRequest, for the response middleware specify the R generic type as a RestRowResponse After extending from the Middleware override the onNext async method and implement your custom logic, after call the next method

await nextMiddleware.next(row)

which will call the next middleware in the chain. Here is the example of request middleware

class CustomMiddleware extends RestMiddleware<RestRowRequest> {

 @override
 Future<RestRowRequest> onNext(
     RestRowRequest row, RestMiddleware<RestRowRequest> nextMiddleware) async {
   // Your logic here
   return await nextMiddleware.next(row);
 }
}

You can also check the RequestLogger and ResponseLogger for more examples.

Implementers

Constructors

Middleware()

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

addNext(Middleware<R> middleWare) → void
This method adds a middleware to the chain. This method is called by the Rest library, no need to call it manually, instead use RestClientBuilder.addRequestMiddleware and RestClientBuilder.addResponseMiddleware
next(R row) Future<R>
This method will call next middleware in the chain. Initially this method get called by the RestClient.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onNext(R row, Middleware<R> nextMiddleware) Future<R>
Override this method and implement your custom logic inside it. After call await nextMiddleware.next(row) to run the next middleware in the chain.
toString() String
A string representation of this object.
inherited

Operators

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