Handler

Trait Handler 

Source
pub trait Handler: Send + Sync {
    // Required method
    fn call(
        &self,
        request: Request<Body>,
        request_data: RequestData,
    ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + '_>>;
}
Expand description

Handler trait that all language bindings must implement

This trait is completely language-agnostic. Each binding (Python, Node, WASM) implements this trait to bridge their runtime to our HTTP server.

Required Methods§

Source

fn call( &self, request: Request<Body>, request_data: RequestData, ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + '_>>

Handle an HTTP request

Takes the extracted request data and returns a future that resolves to either:

  • Ok(Response): A successful HTTP response
  • Err((StatusCode, String)): An error with status code and message

Implementors§