Struct actix_http::HttpServiceBuilder
source · pub struct HttpServiceBuilder<T, S, X = ExpectHandler, U = UpgradeHandler> { /* private fields */ }
Expand description
An HTTP service builder.
This type can construct an instance of HttpService
through a builder-like pattern.
Implementations§
source§impl<T, S, X, U> HttpServiceBuilder<T, S, X, U>where
S: ServiceFactory<Request, Config = ()>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
<S::Service as Service<Request>>::Future: 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<T, Codec>), Config = (), Response = ()>,
U::Error: Display,
U::InitError: Debug,
impl<T, S, X, U> HttpServiceBuilder<T, S, X, U>where
S: ServiceFactory<Request, Config = ()>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
<S::Service as Service<Request>>::Future: 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<T, Codec>), Config = (), Response = ()>,
U::Error: Display,
U::InitError: Debug,
sourcepub fn keep_alive<W: Into<KeepAlive>>(self, val: W) -> Self
pub fn keep_alive<W: Into<KeepAlive>>(self, val: W) -> Self
Set connection keep-alive setting.
Applies to HTTP/1.1 keep-alive and HTTP/2 ping-pong.
By default keep-alive is 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_request_timeout(self, dur: Duration) -> Self
pub fn client_request_timeout(self, dur: Duration) -> Self
Set client request timeout (for first request).
Defines a timeout for reading client request header. If the client does not transmit the
request head within this duration, the connection is terminated with a 408 Request Timeout
response error.
A duration of zero disables the timeout.
By default, the client timeout is 5 seconds.
sourcepub fn client_disconnect_timeout(self, dur: Duration) -> Self
pub fn client_disconnect_timeout(self, dur: Duration) -> Self
Set client connection disconnect timeout.
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.
A duration of zero disables the timeout.
By default, the disconnect timeout is disabled.
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_ext<F>(self, f: F) -> Self
pub fn on_connect_ext<F>(self, f: F) -> Self
Sets the callback to be run on connection establishment.
Has mutable access to a data container that will be merged into request extensions. This enables transport layer data (like client certificates) to be accessed in middleware and handlers.
sourcepub fn h1<F, B>(self, service: F) -> H1Service<T, S, B, X, U>
pub fn h1<F, B>(self, service: F) -> H1Service<T, S, B, X, U>
Finish service configuration and create a service for the 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 a service for the 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.