Struct actix_http::HttpServiceBuilder
source · [−]pub struct HttpServiceBuilder<T, S, X = ExpectHandler, U = UpgradeHandler> { /* private fields */ }
Expand description
A HTTP service builder
This type can be used to construct an instance of HttpService
through a
builder-like pattern.
Implementations
sourceimpl<T, S> HttpServiceBuilder<T, S, ExpectHandler, UpgradeHandler> where
S: ServiceFactory<Request, Config = ()>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
<S::Service as Service<Request>>::Future: 'static,
impl<T, S> HttpServiceBuilder<T, S, ExpectHandler, UpgradeHandler> where
S: ServiceFactory<Request, Config = ()>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
<S::Service as Service<Request>>::Future: 'static,
sourceimpl<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 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> where
F: IntoServiceFactory<X1, Request>,
X1: ServiceFactory<Request, Config = (), Response = Request>,
X1::Error: Into<Response<BoxBody>>,
X1::InitError: Debug,
pub fn expect<F, X1>(self, expect: F) -> HttpServiceBuilder<T, S, X1, U> where
F: IntoServiceFactory<X1, Request>,
X1: ServiceFactory<Request, Config = (), Response = Request>,
X1::Error: Into<Response<BoxBody>>,
X1::InitError: Debug,
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> where
F: IntoServiceFactory<U1, (Request, Framed<T, Codec>)>,
U1: ServiceFactory<(Request, Framed<T, Codec>), Config = (), Response = ()>,
U1::Error: Display,
U1::InitError: Debug,
pub fn upgrade<F, U1>(self, upgrade: F) -> HttpServiceBuilder<T, S, X, U1> where
F: IntoServiceFactory<U1, (Request, Framed<T, Codec>)>,
U1: ServiceFactory<(Request, Framed<T, Codec>), Config = (), Response = ()>,
U1::Error: Display,
U1::InitError: Debug,
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 where
F: Fn(&T, &mut Extensions) + 'static,
pub fn on_connect_ext<F>(self, f: F) -> Self where
F: Fn(&T, &mut Extensions) + 'static,
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> where
B: MessageBody,
F: IntoServiceFactory<S, Request>,
S::Error: Into<Response<BoxBody>>,
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, Request>,
S::Error: Into<Response<BoxBody>>,
S::InitError: Debug,
S::Response: Into<Response<B>>,
Finish service configuration and create a HTTP Service for HTTP/1 protocol.
sourcepub fn h2<F, B>(self, service: F) -> H2Service<T, S, B> where
F: IntoServiceFactory<S, Request>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
B: MessageBody + 'static,
pub fn h2<F, B>(self, service: F) -> H2Service<T, S, B> where
F: IntoServiceFactory<S, Request>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
B: MessageBody + 'static,
Finish service configuration and create a HTTP service for HTTP/2 protocol.
sourcepub fn finish<F, B>(self, service: F) -> HttpService<T, S, B, X, U> where
F: IntoServiceFactory<S, Request>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
B: MessageBody + 'static,
pub fn finish<F, B>(self, service: F) -> HttpService<T, S, B, X, U> where
F: IntoServiceFactory<S, Request>,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
B: MessageBody + 'static,
Finish service configuration and create HttpService
instance.
Auto Trait Implementations
impl<T, S, X = ExpectHandler, U = UpgradeHandler> !RefUnwindSafe for HttpServiceBuilder<T, S, X, U>
impl<T, S, X = ExpectHandler, U = UpgradeHandler> !Send for HttpServiceBuilder<T, S, X, U>
impl<T, S, X = ExpectHandler, U = UpgradeHandler> !Sync for HttpServiceBuilder<T, S, X, U>
impl<T, S, X, U> Unpin for HttpServiceBuilder<T, S, X, U> where
S: Unpin,
U: Unpin,
X: Unpin,
impl<T, S, X = ExpectHandler, U = UpgradeHandler> !UnwindSafe for HttpServiceBuilder<T, S, X, U>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more