Struct HttpServer
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§
§impl HttpServer<Builder>
impl HttpServer<Builder>
pub fn http1() -> HttpServer<Builder>
pub fn http1() -> HttpServer<Builder>
Create a new http/1.1 Builder
with default settings.
pub fn with_guard(self, guard: ShutdownGuard) -> HttpServer<Builder>
pub fn with_guard(self, guard: ShutdownGuard) -> HttpServer<Builder>
Set the guard that can be used by the HttpServer
in case it is turned into an http1 listener.
pub fn maybe_with_guard(
self,
guard: Option<ShutdownGuard>,
) -> HttpServer<Builder>
pub fn maybe_with_guard( self, guard: Option<ShutdownGuard>, ) -> HttpServer<Builder>
Maybe set the guard that can be used by the HttpServer
in case it is turned into an http1 listener.
pub fn set_guard(&mut self, guard: ShutdownGuard) -> &mut HttpServer<Builder>
pub fn set_guard(&mut self, guard: ShutdownGuard) -> &mut HttpServer<Builder>
Set the guard that can be used by the HttpServer
in case it is turned into an http1 listener.
§impl HttpServer<Builder>
impl HttpServer<Builder>
§impl HttpServer<Builder>
impl HttpServer<Builder>
pub fn h2(exec: Executor) -> HttpServer<Builder>
pub fn h2(exec: Executor) -> HttpServer<Builder>
Create a new h2 Builder
with default settings.
§impl HttpServer<Builder>
impl HttpServer<Builder>
§impl HttpServer<Builder>
impl HttpServer<Builder>
pub fn auto(exec: Executor) -> HttpServer<Builder>
pub fn auto(exec: Executor) -> HttpServer<Builder>
Create a new dual http/1.1 + h2 Builder
with default settings.
§impl HttpServer<Builder>
impl HttpServer<Builder>
pub fn http1_mut(&mut self) -> Http1Builder<'_>
pub fn http1_mut(&mut self) -> Http1Builder<'_>
Http1 configuration.
pub fn h2_mut(&mut self) -> Http2Builder<'_>
pub fn h2_mut(&mut self) -> Http2Builder<'_>
H2 configuration.
§impl<B> HttpServer<B>where
B: HttpCoreConnServer,
impl<B> HttpServer<B>where
B: HttpCoreConnServer,
pub 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.
pub async fn serve<S, Response, IO>(
&self,
ctx: Context,
stream: IO,
service: S,
) -> Result<(), Box<dyn Error + Sync + Send>>where
S: Service<Request<Body>, Response = Response, Error = Infallible> + Clone,
Response: IntoResponse + Send + 'static,
IO: Stream,
pub async fn serve<S, Response, IO>(
&self,
ctx: Context,
stream: IO,
service: S,
) -> Result<(), Box<dyn Error + Sync + Send>>where
S: Service<Request<Body>, Response = Response, Error = Infallible> + Clone,
Response: IntoResponse + Send + 'static,
IO: Stream,
Serve a single IO Byte Stream (e.g. a TCP Stream) as HTTP.
pub async fn listen<S, Response, I>(
self,
interface: I,
service: S,
) -> Result<(), Box<dyn Error + Sync + Send>>
pub async fn listen<S, Response, I>( self, interface: I, service: S, ) -> Result<(), Box<dyn Error + Sync + Send>>
Listen for connections on the given Interface
, serving HTTP connections.
It’s a shortcut in case you don’t need to operate on the transport layer directly.
pub async fn listen_unix<S, Response, P>(
self,
path: P,
service: S,
) -> Result<(), Box<dyn Error + Sync + Send>>where
S: Service<Request<Body>, Response = Response, Error = Infallible>,
Response: IntoResponse + Send + 'static,
P: AsRef<Path>,
pub async fn listen_unix<S, Response, P>(
self,
path: P,
service: S,
) -> Result<(), Box<dyn Error + Sync + Send>>where
S: Service<Request<Body>, Response = Response, Error = Infallible>,
Response: IntoResponse + Send + 'static,
P: AsRef<Path>,
Listen for connections on the given Path
, using a unix (domain) socket, serving HTTP connections.
It’s a shortcut in case you don’t need to operate on the unix transport layer directly.
Trait Implementations§
§impl<B> Clone for HttpServer<B>where
B: Clone,
impl<B> Clone for HttpServer<B>where
B: Clone,
§fn clone(&self) -> HttpServer<B>
fn clone(&self) -> HttpServer<B>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto 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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more