File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
tonic/src/transport/channel/service Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 1+ use crate :: body:: Body ;
12use http:: { header:: USER_AGENT , HeaderValue , Request , Uri } ;
23use std:: task:: { Context , Poll } ;
34use tower_service:: Service ;
4- use crate :: body:: Body ;
55
6+ /// A generic request modifier.
7+ ///
8+ /// `Modifier<M, T>` wraps an inner service `T` and applies the
9+ /// modifier `M` to each outgoing `Request`.
10+ ///
11+ /// This type centralizes the boilerplate for implementing
12+ /// request middleware. A modifier is closure which receives
13+ /// the request and mutates it before forwarding to the
14+ /// inner service.
615#[ derive( Debug ) ]
716pub ( crate ) struct Modifier < M , T > {
817 modifier_fn : M ,
3948// and not FnOnce
4049#[ derive( Debug , Clone ) ]
4150pub ( crate ) struct AddOrigin < ' a > {
42- origin : & ' a Uri
51+ origin : & ' a Uri ,
4352}
4453
4554impl < ' a > AddOrigin < ' a > {
@@ -53,9 +62,7 @@ impl<'a> AddOrigin<'a> {
5362 Ok ( Self { origin } )
5463 }
5564
56- pub ( crate ) fn into_fn (
57- self ,
58- ) -> impl FnOnce ( Request < Body > ) -> Request < Body > + Clone {
65+ pub ( crate ) fn into_fn ( self ) -> impl FnOnce ( Request < Body > ) -> Request < Body > + Clone {
5966 let http:: uri:: Parts {
6067 scheme, authority, ..
6168 } = self . origin . clone ( ) . into_parts ( ) ;
@@ -106,9 +113,7 @@ impl UserAgent {
106113 Self { user_agent }
107114 }
108115
109- pub ( crate ) fn into_fn (
110- self ,
111- ) -> impl FnOnce ( Request < Body > ) -> Request < Body > + Clone {
116+ pub ( crate ) fn into_fn ( self ) -> impl FnOnce ( Request < Body > ) -> Request < Body > + Clone {
112117 move |mut req| {
113118 use http:: header:: Entry ;
114119
You can’t perform that action at this time.
0 commit comments