pub struct HttpServer { /* private fields */ }Available on crate feature
http_support only.Expand description
The http server builder.
Implementations§
Source§impl HttpServer
impl HttpServer
Sourcepub fn bind<A: ToSocketAddrs>(laddrs: A) -> Self
pub fn bind<A: ToSocketAddrs>(laddrs: A) -> Self
Create new http server builder with local binding addresses.
Sourcepub fn on(listener: TcpListener) -> Self
pub fn on(listener: TcpListener) -> Self
Create new http server builder with external TcpListener.
Sourcepub fn with_timeout(self, duration: Duration) -> Self
pub fn with_timeout(self, duration: Duration) -> Self
Set the reading timeout duration for newly incoming http request.
The default value is 30s.
Sourcepub fn with_ssl(self, ssl_acceptor: SslAcceptor) -> HttpSslServer
pub fn with_ssl(self, ssl_acceptor: SslAcceptor) -> HttpSslServer
Convert HttpServer into HttpSslServer with provided ssl_acceptor
Sourcepub async fn create(self) -> Result<(TcpListener, Duration)>
pub async fn create(self) -> Result<(TcpListener, Duration)>
Sourcepub async fn serve<H, Fut>(self, handler: H) -> Result<()>where
H: FnMut(Request<BodyReader<TcpStreamRead>>, ResponseWriter<TcpStreamWrite>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<()>> + Send,
pub async fn serve<H, Fut>(self, handler: H) -> Result<()>where
H: FnMut(Request<BodyReader<TcpStreamRead>>, ResponseWriter<TcpStreamWrite>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<()>> + Send,
Consume self and start http server with provided request handler.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HttpServer
impl !RefUnwindSafe for HttpServer
impl Send for HttpServer
impl Sync for HttpServer
impl Unpin 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
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>
Converts
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>
Converts
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