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 aRowRequest, for the response middleware specify the R generic type as a RowResponse 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 Middleware<RowRequest> {

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

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

Implementers

Constructors

Middleware.new()

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 HttpRest library, no need to call it manually, instead use HttpRestClientBuilder.addRequestMiddleware and HttpRestClientBuilder.addResponseMiddleware
next(R row) Future<R>
This method will call next middleware in the chain. Initially this method get called by the HttpRestClient.
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