pub fn option_layer<L>(layer: Option<L>) -> Either<L, Identity>Expand description
Convert an Option<Layer> into a Layer.
use tower::util::option_layer;
// Layer to apply a timeout if configured
let maybe_timeout = option_layer(timeout.map(TimeoutLayer::new));
ServiceBuilder::new()
.layer(maybe_timeout)
.service(svc);