Struct salvo_core::server::Server
source · pub struct Server<A> { /* private fields */ }
Available on crate feature
server
only.Expand description
HTTP Server
A Server
is created to listen on a port, parse HTTP requests, and hand them off to a Service
.
Implementations§
source§impl<A: Acceptor + Send> Server<A>
impl<A: Acceptor + Send> Server<A>
sourcepub fn with_http_builder(acceptor: A, builder: HttpBuilder) -> Self
pub fn with_http_builder(acceptor: A, builder: HttpBuilder) -> Self
Create new Server
with Acceptor
and [HttpBuilder
].
sourcepub fn fuse_factory<F>(self, factory: F) -> Self
pub fn fuse_factory<F>(self, factory: F) -> Self
Set the fuse factory.
sourcepub fn handle(&self) -> ServerHandle
pub fn handle(&self) -> ServerHandle
Get a ServerHandle
to stop server.
sourcepub fn stop_forcible(&self)
pub fn stop_forcible(&self)
Force stop server.
Call this function will stop server immediately.
sourcepub fn stop_graceful(&self, timeout: impl Into<Option<Duration>>)
pub fn stop_graceful(&self, timeout: impl Into<Option<Duration>>)
Graceful stop server.
Call this function will stop server after all connections are closed.
You can specify a timeout to force stop server.
If timeout
is None
, it will wait util all connections are closed.
sourcepub fn http1_mut(&mut self) -> &mut Builder
Available on crate feature http1
only.
pub fn http1_mut(&mut self) -> &mut Builder
http1
only.Use this function to set http1 protocol.
sourcepub fn http2_mut(&mut self) -> &mut Builder<TokioExecutor>
Available on crate feature http2
only.
pub fn http2_mut(&mut self) -> &mut Builder<TokioExecutor>
http2
only.Use this function to set http2 protocol.
sourcepub fn quinn_mut(&mut self) -> &mut Builder
Available on crate feature quinn
only.
pub fn quinn_mut(&mut self) -> &mut Builder
quinn
only.Use this function to set http3 protocol.
Auto Trait Implementations§
impl<A> Freeze for Server<A>where
A: Freeze,
impl<A> !RefUnwindSafe for Server<A>
impl<A> Send for Server<A>where
A: Send,
impl<A> Sync for Server<A>where
A: Sync,
impl<A> Unpin for Server<A>where
A: Unpin,
impl<A> !UnwindSafe for Server<A>
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§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
Mutably borrows from an owned value. Read more