Callback

Trait Callback 

Source
pub trait Callback: Sized {
    // Required method
    fn on_request(
        self,
        req: &Request,
        res: Response,
    ) -> StdResult<Response, ErrorResponse>;
}
Expand description

Callback trait

The callback is called when the server receives an incoming WebSocket handshake request from the client. Specifying a callback allows you to analyze incoming headers and add additional headers to the response that the server sends to the client and / or reject the connection based on the incoming headers.

Required Methods§

Source

fn on_request( self, req: &Request, res: Response, ) -> StdResult<Response, ErrorResponse>

Called whenever the server reads the request from the client and is ready to respond to it. May return additional reply headers. Returning an error resulting in rejecting the incoming connection.

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§