pub struct HttpServer { /* private fields */ }Implementations§
Source§impl HttpServer
impl HttpServer
pub fn new(config: HttpServerConfig) -> Self
Sourcepub fn route<T, Fut>(self, path: impl Into<String>, callback: T) -> Selfwhere
T: Fn(HttpRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HttpResponse> + Send + 'static,
pub fn route<T, Fut>(self, path: impl Into<String>, callback: T) -> Selfwhere
T: Fn(HttpRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = HttpResponse> + Send + 'static,
Registers a route with a path, associating it with a handler callback.
Sourcepub async fn run(self)
pub async fn run(self)
Run 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 HttpServer
impl !RefUnwindSafe for HttpServer
impl Send for HttpServer
impl Sync for HttpServer
impl Unpin for HttpServer
impl UnsafeUnpin for HttpServer
impl !UnwindSafe for HttpServer
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