pingora_core::apps

Trait HttpServerApp

Source
pub trait HttpServerApp {
    // Required method
    fn process_new_http<'life0, 'life1, 'async_trait>(
        self: &'life0 Arc<Self>,
        session: ServerSession,
        shutdown: &'life1 ShutdownWatch,
    ) -> Pin<Box<dyn Future<Output = Option<Stream>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn h2_options(&self) -> Option<H2Options> { ... }
    fn server_options(&self) -> Option<&HttpServerOptions> { ... }
    fn http_cleanup<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

This trait defines the interface of an HTTP application.

Required Methods§

Source

fn process_new_http<'life0, 'life1, 'async_trait>( self: &'life0 Arc<Self>, session: ServerSession, shutdown: &'life1 ShutdownWatch, ) -> Pin<Box<dyn Future<Output = Option<Stream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Similar to the ServerApp, this function is called whenever a new HTTP session is established.

After successful processing, ServerSession::finish() can be called to return an optionally reusable connection back to the service. The caller needs to make sure that the connection is in a reusable state i.e., no error or incomplete read or write headers or bodies. Otherwise a None should be returned.

Provided Methods§

Source

fn h2_options(&self) -> Option<H2Options>

Provide options on how HTTP/2 connection should be established. This function will be called every time a new HTTP/2 connection needs to be established.

A None means to use the built-in default options. See server::H2Options for more details.

Source

fn server_options(&self) -> Option<&HttpServerOptions>

Provide HTTP server options used to override default behavior. This function will be called every time a new connection is processed.

A None means no server options will be applied.

Source

fn http_cleanup<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<SV> HttpServerApp for HttpServer<SV>
where SV: ServeHttp + Send + Sync,

Source§

impl<SV> HttpServerApp for SV
where SV: ServeHttp + Send + Sync,