Struct volo_http::server::Server

source ·
pub struct Server<S, L> { /* private fields */ }

Implementations§

source§

impl<S> Server<S, Identity>

source

pub fn new(service: S) -> Self
where S: Service<HttpContext, BodyIncoming, Response = Response, Error = Infallible>,

source§

impl<S, L> Server<S, L>

source

pub fn register_shutdown_hook( self, hook: impl FnOnce() -> BoxFuture<'static, ()> + 'static + Send ) -> Self

Register shutdown hook.

Hook functions will be called just before volo’s own gracefull existing code starts, in reverse order of registration.

source

pub fn layer<Inner>(self, layer: Inner) -> Server<S, Stack<Inner, L>>

Adds a new inner layer to the server.

The layer’s Service should be Send + Sync + Clone + 'static.

Order

Assume we already have two layers: foo and bar. We want to add a new layer baz.

The current order is: foo -> bar (the request will come to foo first, and then bar).

After we call .layer(baz), we will get: foo -> bar -> baz.

source

pub fn layer_front<Front>(self, layer: Front) -> Server<S, Stack<L, Front>>

Adds a new front layer to the server.

The layer’s Service should be Send + Sync + Clone + 'static.

Order

Assume we already have two layers: foo and bar. We want to add a new layer baz.

The current order is: foo -> bar (the request will come to foo first, and then bar).

After we call .layer_front(baz), we will get: baz -> foo -> bar.

source

pub async fn run<MI: MakeIncoming>( self, mk_incoming: MI ) -> Result<(), BoxError>
where S: Service<HttpContext, BodyIncoming, Response = Response, Error = Infallible>, L: Layer<S>, L::Service: Service<HttpContext, BodyIncoming, Response = Response, Error = Infallible> + Send + Sync + 'static,

Auto Trait Implementations§

§

impl<S, L> !RefUnwindSafe for Server<S, L>

§

impl<S, L> Send for Server<S, L>
where L: Send, S: Send,

§

impl<S, L> !Sync for Server<S, L>

§

impl<S, L> Unpin for Server<S, L>
where L: Unpin, S: Unpin,

§

impl<S, L> !UnwindSafe for Server<S, L>

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, 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, U> TryFrom<U> for T
where 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 T
where 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.
§

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

§

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