Trait rocket::http::hyper::Handler

source ·
pub trait Handler: Sync + Send {
    // Required method
    fn handle<'a, 'k>(&'a self, _: Request<'a, 'k>, _: Response<'a>);

    // Provided methods
    fn check_continue(&self, _: (&Method, &RequestUri, &Headers)) -> StatusCode { ... }
    fn on_connection_start(&self) { ... }
    fn on_connection_end(&self) { ... }
}
Expand description

A handler that can handle incoming requests for a server.

Required Methods§

source

fn handle<'a, 'k>(&'a self, _: Request<'a, 'k>, _: Response<'a>)

Receives a Request/Response pair, and should perform some action on them.

This could reading from the request, and writing to the response.

Provided Methods§

source

fn check_continue(&self, _: (&Method, &RequestUri, &Headers)) -> StatusCode

Called when a Request includes a Expect: 100-continue header.

By default, this will always immediately response with a StatusCode::Continue, but can be overridden with custom behavior.

source

fn on_connection_start(&self)

This is run after a connection is received, on a per-connection basis (not a per-request basis, as a connection with keep-alive may handle multiple requests)

source

fn on_connection_end(&self)

This is run before a connection is closed, on a per-connection basis (not a per-request basis, as a connection with keep-alive may handle multiple requests)

Implementors§

source§

impl<F> Handler for F
where F: Fn(Request<'_, '_>, Response<'_>) + Sync + Send,