pub struct HttpServer<S> { /* private fields */ }
Expand description
An HTTP server.
Implementations§
Source§impl<S> HttpServer<S>
impl<S> HttpServer<S>
Sourcepub fn from_listener(listener: ConnectionOrientedListener, service: S) -> Self
pub fn from_listener(listener: ConnectionOrientedListener, service: S) -> Self
Creates a new HttpServer
from the given listener and service.
§Panics
This will panic if called outside the context of a Tokio runtime.
Sourcepub fn with_tls_config(self, config: ServerConfig) -> Self
pub fn with_tls_config(self, config: ServerConfig) -> Self
Sets the TLS configuration for the server.
This will enable TLS for the server, and the server will only accept connections that are encrypted with TLS.
Defaults to TLS being disabled.
Sourcepub fn with_executor(self, executor: Handle) -> Self
pub fn with_executor(self, executor: Handle) -> Self
Sets the executor for the server.
This executor will be used for spawning tasks to handle incoming connections, but not for the spawn that accepts new connections.
Defaults to the current Tokio runtime at the time HttpServer::new
is called.
Source§impl<S, B> HttpServer<S>
impl<S, B> HttpServer<S>
Sourcepub fn listen(self) -> (ShutdownHandle, ErrorHandle)
pub fn listen(self) -> (ShutdownHandle, ErrorHandle)
Starts the server and listens for incoming connections.
Returns two handles: one for shutting down the server, and one for receiving any errors that occur while the server is running.
Auto Trait Implementations§
impl<S> !Freeze for HttpServer<S>
impl<S> !RefUnwindSafe for HttpServer<S>
impl<S> Send for HttpServer<S>where
S: Send,
impl<S> Sync for HttpServer<S>where
S: Sync,
impl<S> Unpin for HttpServer<S>where
S: Unpin,
impl<S> !UnwindSafe for HttpServer<S>
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
Mutably borrows from an owned value. Read more
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Instruments this type by attaching the given allocation group token, returning a
Tracked
wrapper. Read moreSource§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Instruments this type by attaching the current allocation group, returning a
Tracked
wrapper. Read more