1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 01:32:57 +01:00

allow to specify service config for h1 service

This commit is contained in:
Nikolay Kim 2019-03-04 15:58:39 -08:00
parent b535adf637
commit a88b3b090d
2 changed files with 12 additions and 3 deletions

View File

@ -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)
}
}

View File

@ -34,7 +34,7 @@ where
S::Service: 'static,
B: MessageBody,
{
/// Create new `HttpService` instance.
/// Create new `HttpService` instance with default config.
pub fn new<F: IntoNewService<S>>(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<F: IntoNewService<S>>(cfg: ServiceConfig, service: F) -> Self {
H1Service {
cfg,
srv: service.into_new_service(),
_t: PhantomData,
}
}
/// Create builder for `HttpService` instance.
pub fn build() -> H1ServiceBuilder<T, S> {
H1ServiceBuilder::new()