Struct HttpServiceBuilder

Source
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>>
where S: ServiceFactory<Config = (), Request = Request>, S::Error: Into<Error> + 'static, S::InitError: Debug, <S::Service as Service>::Future: 'static,

Source

pub fn new() -> Self

Create instance of ServiceConfigBuilder

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,

Source

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.

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_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.

Source

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.

Source

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: Into<Error>, X1::InitError: Debug, <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.

Source

pub fn upgrade<F, U1>(self, upgrade: F) -> HttpServiceBuilder<T, S, X, U1>
where F: IntoServiceFactory<U1>, U1: ServiceFactory<Config = (), Request = (Request, Framed<T, Codec>), Response = ()>, U1::Error: Display, U1::InitError: Debug, <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.

Source

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.

Source

pub fn h1<F, B>(self, service: F) -> H1Service<T, S, B, X, U>

Finish service configuration and create http service for HTTP/1 protocol.

Source

pub fn h2<F, B>(self, service: F) -> H2Service<T, S, B>
where B: MessageBody + 'static, F: IntoServiceFactory<S>, S::Error: Into<Error> + '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.

Source

pub fn finish<F, B>(self, service: F) -> HttpService<T, S, B, X, U>
where B: MessageBody + 'static, F: IntoServiceFactory<S>, S::Error: Into<Error> + 'static, S::InitError: Debug, S::Response: Into<Response<B>> + 'static, <S::Service as Service>::Future: 'static,

Finish service configuration and create HttpService instance.

Auto Trait Implementations§

§

impl<T, S, X, U> Freeze for HttpServiceBuilder<T, S, X, U>
where X: Freeze, U: Freeze,

§

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>
where X: Unpin, U: Unpin, T: Unpin, S: Unpin,

§

impl<T, S, X = ExpectHandler, U = UpgradeHandler<T>> !UnwindSafe for HttpServiceBuilder<T, S, X, U>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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 T
where 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
Source§

impl<T> ErasedDestructor for T
where T: 'static,