pub struct HttpServiceBuilder<T, S, X = ExpectHandler, U = UpgradeHandler<T>> { /* private fields */ }
Expand description
A http service builder
This type can be used to construct an instance of http service
through a
builder-like pattern.
Implementations§
Source§impl<T, S> HttpServiceBuilder<T, S, ExpectHandler, UpgradeHandler<T>>
impl<T, S> HttpServiceBuilder<T, S, ExpectHandler, UpgradeHandler<T>>
Source§impl<T, S, X, U> HttpServiceBuilder<T, S, X, U>where
S: ServiceFactory<Config = (), Request = Request>,
S::Error: Into<Error> + 'static,
S::InitError: Debug,
<S::Service as Service>::Future: 'static,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: Into<Error>,
X::InitError: Debug,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display,
U::InitError: Debug,
<U::Service as Service>::Future: 'static,
impl<T, S, X, U> HttpServiceBuilder<T, S, X, U>where
S: ServiceFactory<Config = (), Request = Request>,
S::Error: Into<Error> + 'static,
S::InitError: Debug,
<S::Service as Service>::Future: 'static,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: Into<Error>,
X::InitError: Debug,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>,
U::Error: Display,
U::InitError: Debug,
<U::Service as Service>::Future: 'static,
Sourcepub fn keep_alive<W: Into<KeepAlive>>(self, val: W) -> Self
pub fn keep_alive<W: Into<KeepAlive>>(self, val: W) -> Self
Set server keep-alive setting.
By default keep alive is set to a 5 seconds.
Sourcepub fn local_addr(self, addr: SocketAddr) -> Self
pub fn local_addr(self, addr: SocketAddr) -> Self
Set the local address that this service is bound to.
Sourcepub fn client_timeout(self, val: u64) -> Self
pub fn client_timeout(self, val: u64) -> Self
Set server client timeout in milliseconds for first request.
Defines a timeout for reading client request header. If a client does not transmit the entire set headers within this time, the request is terminated with the 408 (Request Time-out) error.
To disable timeout set value to 0.
By default client timeout is set to 5000 milliseconds.
Sourcepub fn client_disconnect(self, val: u64) -> Self
pub fn client_disconnect(self, val: u64) -> Self
Set server connection disconnect timeout in milliseconds.
Defines a timeout for disconnect connection. If a disconnect procedure does not complete within this time, the request get dropped. This timeout affects secure connections.
To disable timeout set value to 0.
By default disconnect timeout is set to 0.
Sourcepub fn expect<F, X1>(self, expect: F) -> HttpServiceBuilder<T, S, X1, U>
pub fn expect<F, X1>(self, expect: F) -> HttpServiceBuilder<T, S, X1, U>
Provide service for EXPECT: 100-Continue
support.
Service get called with request that contains EXPECT
header.
Service must return request in case of success, in that case
request will be forwarded to main service.
Sourcepub fn upgrade<F, U1>(self, upgrade: F) -> HttpServiceBuilder<T, S, X, U1>
pub fn upgrade<F, U1>(self, upgrade: F) -> HttpServiceBuilder<T, S, X, U1>
Provide service for custom Connection: UPGRADE
support.
If service is provided then normal requests handling get halted and this service get called with original request and framed object.
Sourcepub fn on_connect<F, I>(self, f: F) -> Self
pub fn on_connect<F, I>(self, f: F) -> Self
Set on-connect callback.
It get called once per connection and result of the call get stored to the request’s extensions.
Sourcepub fn h1<F, B>(self, service: F) -> H1Service<T, S, B, X, U>where
B: MessageBody,
F: IntoServiceFactory<S>,
S::Error: Into<Error>,
S::InitError: Debug,
S::Response: Into<Response<B>>,
pub fn h1<F, B>(self, service: F) -> H1Service<T, S, B, X, U>where
B: MessageBody,
F: IntoServiceFactory<S>,
S::Error: Into<Error>,
S::InitError: Debug,
S::Response: Into<Response<B>>,
Finish service configuration and create http service for HTTP/1 protocol.
Sourcepub fn h2<F, B>(self, service: F) -> H2Service<T, S, B>
pub fn h2<F, B>(self, service: F) -> H2Service<T, S, B>
Finish service configuration and create http service for HTTP/2 protocol.
Sourcepub fn finish<F, B>(self, service: F) -> HttpService<T, S, B, X, U>
pub fn finish<F, B>(self, service: F) -> HttpService<T, S, B, X, U>
Finish service configuration and create HttpService
instance.
Auto Trait Implementations§
impl<T, S, X, U> Freeze for HttpServiceBuilder<T, S, X, U>
impl<T, S, X = ExpectHandler, U = UpgradeHandler<T>> !RefUnwindSafe for HttpServiceBuilder<T, S, X, U>
impl<T, S, X = ExpectHandler, U = UpgradeHandler<T>> !Send for HttpServiceBuilder<T, S, X, U>
impl<T, S, X = ExpectHandler, U = UpgradeHandler<T>> !Sync for HttpServiceBuilder<T, S, X, U>
impl<T, S, X, U> Unpin for HttpServiceBuilder<T, S, X, U>
impl<T, S, X = ExpectHandler, U = UpgradeHandler<T>> !UnwindSafe for HttpServiceBuilder<T, S, X, U>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more