File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88# Unreleased
99
1010- ** builder** : Implement ` Layer ` for ` ServiceBuilder ` .
11+ - ** builder** : Add ` ServiceBuilder::and_then ` analogous to
12+ ` ServiceExt::and_then `
1113
1214# 0.4.8 (May 28, 2021)
1315
Original file line number Diff line number Diff line change @@ -453,6 +453,28 @@ impl<L> ServiceBuilder<L> {
453453 self . layer ( crate :: util:: ThenLayer :: new ( f) )
454454 }
455455
456+ /// Executes a new future after this service's future resolves. This does
457+ /// not alter the behaviour of the [`poll_ready`] method.
458+ ///
459+ /// This method can be used to change the [`Response`] type of the service
460+ /// into a different type. You can use this method to chain along a computation once the
461+ /// service's response has been resolved.
462+ ///
463+ /// This wraps the inner service with an instance of the [`AndThen`]
464+ /// middleware.
465+ ///
466+ /// See the documentation for the [`and_then` combinator] for details.
467+ ///
468+ /// [`Response`]: crate::Service::Response
469+ /// [`poll_ready`]: crate::Service::poll_ready
470+ /// [`and_then` combinator]: crate::util::ServiceExt::and_then
471+ /// [`AndThen`]: crate::util::AndThen
472+ #[ cfg( feature = "util" ) ]
473+ #[ cfg_attr( docsrs, doc( cfg( feature = "util" ) ) ) ]
474+ pub fn and_then < F > ( self , f : F ) -> ServiceBuilder < Stack < crate :: util:: AndThenLayer < F > , L > > {
475+ self . layer ( crate :: util:: AndThenLayer :: new ( f) )
476+ }
477+
456478 /// Maps this service's result type (`Result<Self::Response, Self::Error>`)
457479 /// to a different value, regardless of whether the future succeeds or
458480 /// fails.
You can’t perform that action at this time.
0 commit comments