The correct behavior is build's. We introduced the config object as a nice way to register middleware within routing; users can always register middleware in A position by wrapping the built Service with tower::Layers as they'd do with any other Service.
When fixing this:
document in the Rust docs for the generated config object that layers get run in B position, HTTP plugins in C position, and model plugins in D position.
Call out how to add a layer in A position.
add a test to our example Pokemon service that ensures that middleware gets invoked in ABCD order regardless of whether we use build or build_unchecked.
build()
returns:So the
.layer
s registered inconfig
will run in B position after routing.On the other hand,
build_unchecked()
returns:So the
.layer
s run in A position, before routing.The correct behavior is
build
's. We introduced the config object as a nice way to register middleware within routing; users can always register middleware in A position by wrapping the builtService
withtower::Layer
s as they'd do with any otherService
.When fixing this:
build
orbuild_unchecked
.