Pipeline class

A helper that makes it easy to compose a set of Middleware and a Handler.

Middleware are executed in the order they are added, processing the request top-down and the response bottom-up.

Basic Pipeline

var handler = const Pipeline()
    .addMiddleware(loggingMiddleware)
    .addMiddleware(cachingMiddleware)
    .addHandler(application);

Execution Order

// Request flows down:
// 1. Logging middleware (request)
// 2. Auth middleware (request)
// 3. Handler
// 4. Auth middleware (response)
// 5. Logging middleware (response)

final handler = const Pipeline()
    .addMiddleware(loggingMiddleware)    // First to see request
    .addMiddleware(authMiddleware)       // Second to see request
    .addHandler(apiHandler);             // Last to process

Note: this package also provides addMiddleware and addHandler extensions members on Middleware, which may be easier to use.

Constructors

Pipeline()
Creates a new, empty pipeline.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
middleware Middleware
Exposes this pipeline of Middleware as a single middleware instance.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addHandler(Handler handler) Handler
Returns a new Handler with handler as the final processor of a Request if all of the middleware in the pipeline have passed the request through.
addMiddleware(Middleware middleware) Pipeline
Returns a new Pipeline with middleware added to the existing set of Middleware.
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