Struct HttpContext
pub struct HttpContext { /* private fields */ }Expand description
This struct represents the shared configuration and context for a http server.
This currently contains tunable parameters in a HttpConfig, the Swansong graceful
shutdown control interface, and a shared TypeSet that contains application-specific
information about the running server
Implementations§
§impl HttpContext
impl HttpContext
pub fn config(&self) -> &HttpConfig
pub fn config(&self) -> &HttpConfig
Borrows HttpConfig performance and security parameters
pub fn config_mut(&mut self) -> &mut HttpConfig
pub fn config_mut(&mut self) -> &mut HttpConfig
Mutably borrow HttpConfig performance and security parameters
pub fn set_config(&mut self, config: HttpConfig) -> &mut HttpContext
pub fn set_config(&mut self, config: HttpConfig) -> &mut HttpContext
Sets HttpConfig performance and security parameters, returning &mut Self for chaining
pub fn with_config(self, config: HttpConfig) -> HttpContext
pub fn with_config(self, config: HttpConfig) -> HttpContext
Owned chainable setter for HttpConfig performance and security parameters, returning Self
pub fn swansong_mut(&mut self) -> &mut Swansong
pub fn swansong_mut(&mut self) -> &mut Swansong
Mutably borrow Swansong graceful shutdown interface
pub fn set_swansong(&mut self, swansong: Swansong) -> &mut HttpContext
pub fn set_swansong(&mut self, swansong: Swansong) -> &mut HttpContext
Sets Swansong graceful shutdown interface, returning &mut Self for chaining
pub fn with_swansong(self, swansong: Swansong) -> HttpContext
pub fn with_swansong(self, swansong: Swansong) -> HttpContext
Owned chainable setter for Swansong graceful shutdown interface, returning Self
Borrows TypeSet shared state
Mutably borrow TypeSet shared state
Sets TypeSet shared state, returning &mut Self for chaining
Owned chainable setter for TypeSet shared state, returning Self
§impl HttpContext
impl HttpContext
pub fn new() -> HttpContext
pub fn new() -> HttpContext
Construct a new HttpContext
pub async fn run<Transport, Handler, Fut>(
self: Arc<HttpContext>,
transport: Transport,
handler: Handler,
) -> Result<Option<Upgrade<Transport>>, Error>
pub async fn run<Transport, Handler, Fut>( self: Arc<HttpContext>, transport: Transport, handler: Handler, ) -> Result<Option<Upgrade<Transport>>, Error>
Perform HTTP on the provided transport, applying the provided async Conn -> Conn handler
function for every distinct http request-response.
For any given invocation of HttpContext::run, the handler function may run any number of
times, depending on whether the connection is reused by the client.
This can only be called on an Arc<HttpContext> because an arc clone is moved into the
Conn.
§Errors
This function will return an Error if any of the http requests is
irrecoverably malformed or otherwise noncompliant.
pub fn shut_down(&self) -> ShutdownCompletion
pub fn shut_down(&self) -> ShutdownCompletion
Attempt graceful shutdown of this server.
The returned ShutdownCompletion type can
either be awaited in an async context or blocked on with ShutdownCompletion::block in a
blocking context