pub struct HttpServer<B> { /* private fields */ }
Expand description
A builder for configuring and listening over HTTP using a Service
.
Supported Protocols: HTTP/1, H2, Auto (HTTP/1 + H2)
Implementations§
Source§impl HttpServer<Builder>
impl HttpServer<Builder>
Sourcepub fn with_guard(self, guard: ShutdownGuard) -> Self
pub fn with_guard(self, guard: ShutdownGuard) -> Self
Set the guard that can be used by the HttpServer
in case it is turned into an http1 listener.
Sourcepub fn maybe_with_guard(self, guard: Option<ShutdownGuard>) -> Self
pub fn maybe_with_guard(self, guard: Option<ShutdownGuard>) -> Self
Maybe set the guard that can be used by the HttpServer
in case it is turned into an http1 listener.
Sourcepub fn set_guard(&mut self, guard: ShutdownGuard) -> &mut Self
pub fn set_guard(&mut self, guard: ShutdownGuard) -> &mut Self
Set the guard that can be used by the HttpServer
in case it is turned into an http1 listener.
Source§impl HttpServer<Builder>
impl HttpServer<Builder>
Sourcepub fn http1_mut(&mut self) -> &mut Http1ConnBuilder
pub fn http1_mut(&mut self) -> &mut Http1ConnBuilder
Http1 configuration.
Source§impl HttpServer<Builder>
impl HttpServer<Builder>
Source§impl HttpServer<Builder>
impl HttpServer<Builder>
Sourcepub fn h2_mut(&mut self) -> &mut H2ConnBuilder
pub fn h2_mut(&mut self) -> &mut H2ConnBuilder
H2 configuration.
Source§impl HttpServer<Builder>
impl HttpServer<Builder>
Source§impl HttpServer<Builder>
impl HttpServer<Builder>
Sourcepub fn http1_mut(&mut self) -> InnerAutoHttp1Builder<'_>
pub fn http1_mut(&mut self) -> InnerAutoHttp1Builder<'_>
Http1 configuration.
Sourcepub fn h2_mut(&mut self) -> InnerAutoHttp2Builder<'_>
pub fn h2_mut(&mut self) -> InnerAutoHttp2Builder<'_>
H2 configuration.
Source§impl<B> HttpServer<B>where
B: HttpCoreConnServer,
impl<B> HttpServer<B>where
B: HttpCoreConnServer,
Sourcepub fn service<S>(self, service: S) -> HttpService<B, S>
pub fn service<S>(self, service: S) -> HttpService<B, S>
Turn this HttpServer
into a Service
that can be used to serve
IO Byte streams (e.g. a TCP Stream) as HTTP.
Sourcepub async fn serve<State, S, Response, IO>(
&self,
ctx: Context<State>,
stream: IO,
service: S,
) -> HttpServeResultwhere
State: Clone + Send + Sync + 'static,
S: Service<State, Request, Response = Response, Error = Infallible> + Clone,
Response: IntoResponse + Send + 'static,
IO: Stream,
pub async fn serve<State, S, Response, IO>(
&self,
ctx: Context<State>,
stream: IO,
service: S,
) -> HttpServeResultwhere
State: Clone + Send + Sync + 'static,
S: Service<State, Request, Response = Response, Error = Infallible> + Clone,
Response: IntoResponse + Send + 'static,
IO: Stream,
Serve a single IO Byte Stream (e.g. a TCP Stream) as HTTP.
Sourcepub async fn listen<S, Response, A>(
self,
addr: A,
service: S,
) -> HttpServeResultwhere
S: Service<(), Request, Response = Response, Error = Infallible>,
Response: IntoResponse + Send + 'static,
A: ToSocketAddrs,
pub async fn listen<S, Response, A>(
self,
addr: A,
service: S,
) -> HttpServeResultwhere
S: Service<(), Request, Response = Response, Error = Infallible>,
Response: IntoResponse + Send + 'static,
A: ToSocketAddrs,
Listen for connections on the given address, serving HTTP connections.
It’s a shortcut in case you don’t need to operate on the transport layer directly.
Sourcepub async fn listen_with_state<State, S, Response, A>(
self,
state: State,
addr: A,
service: S,
) -> HttpServeResultwhere
State: Clone + Send + Sync + 'static,
S: Service<State, Request, Response = Response, Error = Infallible>,
Response: IntoResponse + Send + 'static,
A: ToSocketAddrs,
pub async fn listen_with_state<State, S, Response, A>(
self,
state: State,
addr: A,
service: S,
) -> HttpServeResultwhere
State: Clone + Send + Sync + 'static,
S: Service<State, Request, Response = Response, Error = Infallible>,
Response: IntoResponse + Send + 'static,
A: ToSocketAddrs,
Listen for connections on the given address, serving HTTP connections.
Same as Self::listen
, but including the given state in the Service
’s Context
.
Trait Implementations§
Source§impl<B> Clone for HttpServer<B>where
B: Clone,
impl<B> Clone for HttpServer<B>where
B: Clone,
Auto Trait Implementations§
impl<B> Freeze for HttpServer<B>where
B: Freeze,
impl<B> RefUnwindSafe for HttpServer<B>where
B: RefUnwindSafe,
impl<B> Send for HttpServer<B>where
B: Send,
impl<B> Sync for HttpServer<B>where
B: Sync,
impl<B> Unpin for HttpServer<B>where
B: Unpin,
impl<B> UnwindSafe for HttpServer<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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