Struct ntex::http::HttpServiceBuilder [−][src]
pub struct HttpServiceBuilder<T, S, X = ExpectHandler, U = UpgradeHandler<T>> { /* fields omitted */ }
Expand description
A http service builder
This type can be used to construct an instance of http service
through a
builder-like pattern.
Implementations
impl<T, S, X, U> HttpServiceBuilder<T, S, X, U> where
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError + 'static,
S::InitError: Debug,
S::Future: 'static,
<S::Service as Service>::Future: 'static,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: ResponseError + 'static,
X::InitError: Debug,
X::Future: 'static,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, T, State, Codec), Response = ()>,
U::Error: Display + Error + 'static,
U::InitError: Debug,
U::Future: 'static,
<U::Service as Service>::Future: 'static,
impl<T, S, X, U> HttpServiceBuilder<T, S, X, U> where
S: ServiceFactory<Config = (), Request = Request>,
S::Error: ResponseError + 'static,
S::InitError: Debug,
S::Future: 'static,
<S::Service as Service>::Future: 'static,
X: ServiceFactory<Config = (), Request = Request, Response = Request>,
X::Error: ResponseError + 'static,
X::InitError: Debug,
X::Future: 'static,
<X::Service as Service>::Future: 'static,
U: ServiceFactory<Config = (), Request = (Request, T, State, Codec), Response = ()>,
U::Error: Display + Error + 'static,
U::InitError: Debug,
U::Future: 'static,
<U::Service as Service>::Future: 'static,
Set server keep-alive setting.
By default keep alive is set to a 5 seconds.
Set server client timeout 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 3 seconds.
Set server connection disconnect timeout in seconds.
Defines a timeout for disconnect connection. If a disconnect procedure does not complete within this time, the connection get dropped.
To disable timeout set value to 0.
By default disconnect timeout is set to 3 seconds.
Set server ssl handshake timeout.
Defines a timeout for connection ssl handshake negotiation. To disable timeout set value to 0.
By default handshake timeout is set to 5 seconds.
pub fn buffer_params(
self,
max_read_buf_size: u16,
max_write_buf_size: u16,
min_buf_size: u16
) -> Self
pub fn buffer_params(
self,
max_read_buf_size: u16,
max_write_buf_size: u16,
min_buf_size: u16
) -> Self
Set read/write buffer params
By default read buffer is 8kb, write buffer is 8kb
pub fn expect<F, X1>(self, expect: F) -> HttpServiceBuilder<T, S, X1, U> where
F: IntoServiceFactory<X1>,
X1: ServiceFactory<Config = (), Request = Request, Response = Request>,
X1::Error: ResponseError + 'static,
X1::InitError: Debug,
X1::Future: 'static,
<X1::Service as Service>::Future: 'static,
pub fn expect<F, X1>(self, expect: F) -> HttpServiceBuilder<T, S, X1, U> where
F: IntoServiceFactory<X1>,
X1: ServiceFactory<Config = (), Request = Request, Response = Request>,
X1::Error: ResponseError + 'static,
X1::InitError: Debug,
X1::Future: 'static,
<X1::Service as Service>::Future: 'static,
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.
pub fn upgrade<F, U1>(self, upgrade: F) -> HttpServiceBuilder<T, S, X, U1> where
F: IntoServiceFactory<U1>,
U1: ServiceFactory<Config = (), Request = (Request, T, State, Codec), Response = ()>,
U1::Error: Display + Error + 'static,
U1::InitError: Debug,
U1::Future: 'static,
<U1::Service as Service>::Future: 'static,
pub fn upgrade<F, U1>(self, upgrade: F) -> HttpServiceBuilder<T, S, X, U1> where
F: IntoServiceFactory<U1>,
U1: ServiceFactory<Config = (), Request = (Request, T, State, Codec), Response = ()>,
U1::Error: Display + Error + 'static,
U1::InitError: Debug,
U1::Future: 'static,
<U1::Service as Service>::Future: 'static,
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.
pub fn on_connect<F, I>(self, f: F) -> Self where
F: Fn(&T) -> I + 'static,
I: Clone + 'static,
pub fn on_connect<F, I>(self, f: F) -> Self where
F: Fn(&T) -> I + 'static,
I: Clone + 'static,
Set on-connect callback.
It get called once per connection and result of the call get stored to the request’s extensions.
Set req request callback.
It get called once per request.
pub fn h1<F, B>(self, service: F) -> H1Service<T, S, B, X, U> where
B: MessageBody,
F: IntoServiceFactory<S>,
S::Error: ResponseError,
S::InitError: Debug,
S::Response: Into<Response<B>>,
S::Future: 'static,
pub fn h1<F, B>(self, service: F) -> H1Service<T, S, B, X, U> where
B: MessageBody,
F: IntoServiceFactory<S>,
S::Error: ResponseError,
S::InitError: Debug,
S::Response: Into<Response<B>>,
S::Future: 'static,
Finish service configuration and create http service for HTTP/1 protocol.
pub fn h2<F, B>(self, service: F) -> H2Service<T, S, B> where
B: MessageBody + 'static,
F: IntoServiceFactory<S>,
S::Error: ResponseError + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
pub fn h2<F, B>(self, service: F) -> H2Service<T, S, B> where
B: MessageBody + 'static,
F: IntoServiceFactory<S>,
S::Error: ResponseError + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service>::Future: 'static,
Finish service configuration and create http service for HTTP/2 protocol.
pub fn finish<F, B>(self, service: F) -> HttpService<T, S, B, X, U> where
B: MessageBody + 'static,
F: IntoServiceFactory<S>,
S::Error: ResponseError + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
S::Future: 'static,
<S::Service as Service>::Future: 'static,
pub fn finish<F, B>(self, service: F) -> HttpService<T, S, B, X, U> where
B: MessageBody + 'static,
F: IntoServiceFactory<S>,
S::Error: ResponseError + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
S::Future: 'static,
<S::Service as Service>::Future: 'static,
Finish service configuration and create HttpService
instance.