@@ -12,7 +12,11 @@ mod unix;
12
12
use tokio_stream:: StreamExt as _;
13
13
use tracing:: { debug, trace} ;
14
14
15
- use crate :: service:: Routes ;
15
+ #[ cfg( feature = "router" ) ]
16
+ use crate :: { server:: NamedService , service:: Routes } ;
17
+
18
+ #[ cfg( feature = "router" ) ]
19
+ use std:: convert:: Infallible ;
16
20
17
21
pub use conn:: { Connected , TcpConnectInfo } ;
18
22
use hyper_util:: {
@@ -40,15 +44,13 @@ use crate::transport::Error;
40
44
use self :: service:: { ConnectInfoLayer , RecoverError , ServerIo } ;
41
45
use super :: service:: GrpcTimeout ;
42
46
use crate :: body:: Body ;
43
- use crate :: server:: NamedService ;
44
47
use bytes:: Bytes ;
45
48
use http:: { Request , Response } ;
46
49
use http_body_util:: BodyExt ;
47
50
use hyper:: { body:: Incoming , service:: Service as HyperService } ;
48
51
use pin_project:: pin_project;
49
52
use std:: future:: pending;
50
53
use std:: {
51
- convert:: Infallible ,
52
54
fmt,
53
55
future:: { self , poll_fn, Future } ,
54
56
marker:: PhantomData ,
@@ -132,6 +134,7 @@ impl Default for Server<Identity> {
132
134
}
133
135
134
136
/// A stack based [`Service`] router.
137
+ #[ cfg( feature = "router" ) ]
135
138
#[ derive( Debug ) ]
136
139
pub struct Router < L = Identity > {
137
140
server : Server < L > ,
@@ -393,6 +396,7 @@ impl<L> Server<L> {
393
396
///
394
397
/// This will clone the `Server` builder and create a router that will
395
398
/// route around different services.
399
+ #[ cfg( feature = "router" ) ]
396
400
pub fn add_service < S > ( & mut self , svc : S ) -> Router < L >
397
401
where
398
402
S : Service < Request < Body > , Error = Infallible >
@@ -416,6 +420,7 @@ impl<L> Server<L> {
416
420
/// # Note
417
421
/// Even when the argument given is `None` this will capture *all* requests to this service name.
418
422
/// As a result, one cannot use this to toggle between two identically named implementations.
423
+ #[ cfg( feature = "router" ) ]
419
424
pub fn add_optional_service < S > ( & mut self , svc : Option < S > ) -> Router < L >
420
425
where
421
426
S : Service < Request < Body > , Error = Infallible >
@@ -436,6 +441,7 @@ impl<L> Server<L> {
436
441
///
437
442
/// This will clone the `Server` builder and create a router that will
438
443
/// route around different services that were already added to the provided `routes`.
444
+ #[ cfg( feature = "router" ) ]
439
445
pub fn add_routes ( & mut self , routes : Routes ) -> Router < L >
440
446
where
441
447
L : Clone ,
@@ -815,12 +821,14 @@ async fn sleep_or_pending(wait_for: Option<Duration>) {
815
821
} ;
816
822
}
817
823
824
+ #[ cfg( feature = "router" ) ]
818
825
impl < L > Router < L > {
819
826
pub ( crate ) fn new ( server : Server < L > , routes : Routes ) -> Self {
820
827
Self { server, routes }
821
828
}
822
829
}
823
830
831
+ #[ cfg( feature = "router" ) ]
824
832
impl < L > Router < L > {
825
833
/// Add a new service to this router.
826
834
pub fn add_service < S > ( mut self , svc : S ) -> Self
0 commit comments