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,

source

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.

source

pub fn secure(self) -> Self

Set connection secure state

source

pub fn local_addr(self, addr: SocketAddr) -> Self

Set the local address that this service is bound to.

source

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.

source

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.

source

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.

source

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.

source

pub fn on_connect_ext<F>(self, f: F) -> Selfwhere 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.

source

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 service for the HTTP/1 protocol.

source

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 service for the HTTP/2 protocol.

source

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.

Trait Implementations§

source§

impl<T, S> Default for 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,

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more