diff --git a/src/config.rs b/src/config.rs index 960f13706..a9e705c95 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,7 +65,7 @@ impl Default for ServiceConfig { impl ServiceConfig { /// Create instance of `ServiceConfig` - pub(crate) fn new( + pub fn new( keep_alive: KeepAlive, client_timeout: u64, client_disconnect: u64, @@ -282,7 +282,7 @@ impl ServiceConfigBuilder { } /// Finish service configuration and create `ServiceConfig` object. - pub fn finish(self) -> ServiceConfig { + pub fn finish(&mut self) -> ServiceConfig { ServiceConfig::new(self.keep_alive, self.client_timeout, self.client_disconnect) } } diff --git a/src/h1/service.rs b/src/h1/service.rs index 4beb4c9e4..4c1fb9a82 100644 --- a/src/h1/service.rs +++ b/src/h1/service.rs @@ -34,7 +34,7 @@ where S::Service: 'static, B: MessageBody, { - /// Create new `HttpService` instance. + /// Create new `HttpService` instance with default config. pub fn new>(service: F) -> Self { let cfg = ServiceConfig::new(KeepAlive::Timeout(5), 5000, 0); @@ -45,6 +45,15 @@ where } } + /// Create new `HttpService` instance with config. + pub fn with_config>(cfg: ServiceConfig, service: F) -> Self { + H1Service { + cfg, + srv: service.into_new_service(), + _t: PhantomData, + } + } + /// Create builder for `HttpService` instance. pub fn build() -> H1ServiceBuilder { H1ServiceBuilder::new()