Function tower::util::option_layer [−][src]
pub fn option_layer<L>(layer: Option<L>) -> Either<L, Identity>ⓘ
This is supported on crate feature
util
only.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);