Skip to main content

compose_middleware_pipeline

Function compose_middleware_pipeline 

Source
pub fn compose_middleware_pipeline(
    primary: Vec<u8>,
    middlewares: Vec<Middleware>,
) -> Result<Vec<u8>>
Expand description

Composes middlewares into a pipeline in front of the primary component.

middlewares is ordered from outermost (first to receive a request) to innermost (last before the primary component). Each middleware has the deny adapter applied according to its InheritConfiguration before being wired into the pipeline.

Each component’s MIDDLEWARE_HANDLER_INTERFACE import and export are located by semver compatibility with 0.3, so components built against different 0.3.x versions of wasi:http can be mixed. wac-graph merges the semver-compatible wasi:http/types imports into a single import at the highest version, so all components share one set of HTTP resources.

The composed component exports MIDDLEWARE_HANDLER_INTERFACE at the highest 0.3.x version exported by any component in the pipeline, backed by the outermost middleware. If middlewares is empty, primary is returned unchanged.