pub struct HttpReceiver { /* private fields */ }
Implementations§
Source§impl HttpReceiver
impl HttpReceiver
Sourcepub fn new<T: AsRef<str>>(host: T) -> Self
pub fn new<T: AsRef<str>>(host: T) -> Self
Creates a new HttpReceiver
instance bound to the specified host address. Example: 127.0.0.1:8080
.
Sourcepub fn tls<T: AsRef<Path>>(
self,
tls_server_cert_path: T,
tls_server_key_path: T,
) -> Self
pub fn tls<T: AsRef<Path>>( self, tls_server_cert_path: T, tls_server_key_path: T, ) -> Self
Enables TLS for incoming connections using the provided server certificate and private key in .pem
format and
configures the TLS context and sets supported ALPN protocols to allow HTTP/2 and HTTP/1.1.
Sourcepub fn route<T, Fut, S>(self, path: S, callback: T) -> Selfwhere
T: Fn(String, HttpRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HttpResponse> + Send + 'static,
S: AsRef<str>,
pub fn route<T, Fut, S>(self, path: S, callback: T) -> Selfwhere
T: Fn(String, HttpRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HttpResponse> + Send + 'static,
S: AsRef<str>,
Registers a route with a path, associating it with a handler callback.
Sourcepub async fn receive(self)
pub async fn receive(self)
Starts the HTTP server and begins listening for incoming TCP connections (optionally over TLS).
This method binds to the configured host address and enters a loop to accept new TCP connections. It also listens for system termination signals (SIGINT, SIGTERM) to gracefully shut down the server.
Auto Trait Implementations§
impl !Freeze for HttpReceiver
impl !RefUnwindSafe for HttpReceiver
impl Send for HttpReceiver
impl Sync for HttpReceiver
impl Unpin for HttpReceiver
impl !UnwindSafe for HttpReceiver
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