Trait ServerModuleHandlers

Source
pub trait ServerModuleHandlers {
    // Required methods
    fn request_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        request: RequestData,
        config: &'life1 Yaml,
        socket_data: &'life2 SocketData,
        error_logger: &'life3 ErrorLogger,
    ) -> Pin<Box<dyn Future<Output = Result<ResponseData, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn proxy_request_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        request: RequestData,
        config: &'life1 Yaml,
        socket_data: &'life2 SocketData,
        error_logger: &'life3 ErrorLogger,
    ) -> Pin<Box<dyn Future<Output = Result<ResponseData, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn response_modifying_handler<'life0, 'async_trait>(
        &'life0 mut self,
        response: Response<BoxBody<Bytes, Error>>,
    ) -> Pin<Box<dyn Future<Output = Result<Response<BoxBody<Bytes, Error>>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn proxy_response_modifying_handler<'life0, 'async_trait>(
        &'life0 mut self,
        response: Response<BoxBody<Bytes, Error>>,
    ) -> Pin<Box<dyn Future<Output = Result<Response<BoxBody<Bytes, Error>>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn connect_proxy_request_handler<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        upgraded_request: Upgraded,
        connect_address: &'life1 str,
        config: &'life2 Yaml,
        socket_data: &'life3 SocketData,
        error_logger: &'life4 ErrorLogger,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn does_connect_proxy_requests(&mut self) -> bool;
    fn websocket_request_handler<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        websocket: HyperWebsocket,
        uri: &'life1 Uri,
        config: &'life2 Yaml,
        socket_data: &'life3 SocketData,
        error_logger: &'life4 ErrorLogger,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn does_websocket_requests(
        &mut self,
        config: &Yaml,
        socket_data: &SocketData,
    ) -> bool;
}
Expand description

Defines the interface for server module handlers, specifying how requests should be processed.

Required Methods§

Source

fn request_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, request: RequestData, config: &'life1 Yaml, socket_data: &'life2 SocketData, error_logger: &'life3 ErrorLogger, ) -> Pin<Box<dyn Future<Output = Result<ResponseData, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Handles an incoming request.

§Parameters
  • request: A RequestData object containing the incoming request and associated data.
  • config: A reference to the combined server configuration (ServerConfig). The combined configuration has properties in its root.
  • socket_data: A reference to the SocketData containing socket-related information.
  • error_logger: A reference to an ErrorLogger for logging errors.
§Returns

A Result containing a ResponseData object upon success, or a boxed dyn Error if an error occurs.

Source

fn proxy_request_handler<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, request: RequestData, config: &'life1 Yaml, socket_data: &'life2 SocketData, error_logger: &'life3 ErrorLogger, ) -> Pin<Box<dyn Future<Output = Result<ResponseData, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Handles an incoming forward proxy request (not using CONNECT method).

§Parameters
  • request: A RequestData object containing the incoming request and associated data.
  • config: A reference to the combined server configuration (ServerConfig). The combined configuration has properties in its root.
  • socket_data: A reference to the SocketData containing socket-related information.
  • error_logger: A reference to an ErrorLogger for logging errors.
§Returns

A Result containing a ResponseData object upon success, or a boxed dyn Error if an error occurs.

Source

fn response_modifying_handler<'life0, 'async_trait>( &'life0 mut self, response: Response<BoxBody<Bytes, Error>>, ) -> Pin<Box<dyn Future<Output = Result<Response<BoxBody<Bytes, Error>>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Modifies an outgoing response before it is sent to the client.

This function allows for inspection and modification of the response generated by the server or other handlers. Implementers can use this to add, remove, or alter headers, change the status code, or modify the body of the response as needed.

§Parameters
  • response: A HyperResponse object representing the outgoing HTTP response.
§Returns

A Result containing the potentially modified HyperResponse object upon success, or a boxed dyn Error if an error occurs during processing.

Source

fn proxy_response_modifying_handler<'life0, 'async_trait>( &'life0 mut self, response: Response<BoxBody<Bytes, Error>>, ) -> Pin<Box<dyn Future<Output = Result<Response<BoxBody<Bytes, Error>>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Modifies an outgoing response for forward proxy requests (not using CONNECT method) before it is sent to the client.

This function allows for inspection and modification of the response generated by the server or other handlers. Implementers can use this to add, remove, or alter headers, change the status code, or modify the body of the response as needed.

§Parameters
  • response: A HyperResponse object representing the outgoing HTTP response.
§Returns

A Result containing the potentially modified HyperResponse object upon success, or a boxed dyn Error if an error occurs during processing.

Source

fn connect_proxy_request_handler<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, upgraded_request: Upgraded, connect_address: &'life1 str, config: &'life2 Yaml, socket_data: &'life3 SocketData, error_logger: &'life4 ErrorLogger, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Handles an incoming forward proxy request (using CONNECT method).

§Parameters
  • upgraded_request: A HyperUpgraded object containing the upgraded HTTP connection.
  • connect_address: A reference to a string containing the address and port number of the destination server (for example “example.com:443”).
  • config: A reference to the combined server configuration (ServerConfig). The combined configuration has properties in its root.
  • socket_data: A reference to the SocketData containing socket-related information.
  • error_logger: A reference to an ErrorLogger for logging errors.
§Returns

A Result containing an empty value upon success, or a boxed dyn Error if an error occurs.

Source

fn does_connect_proxy_requests(&mut self) -> bool

Checks if the module is a forward proxy module utilizing CONNECT method.

§Returns

true if the module is a forward proxy module utlilzing CONNECT method, or false otherwise.

Source

fn websocket_request_handler<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, websocket: HyperWebsocket, uri: &'life1 Uri, config: &'life2 Yaml, socket_data: &'life3 SocketData, error_logger: &'life4 ErrorLogger, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Handles an incoming WebSocket request.

§Parameters
  • websocket: A HyperWebsocket object containing a future that resolves to a WebSocket stream.
  • uri: A hyper::Uri object containig the HTTP request URI.
  • config: A reference to the combined server configuration (ServerConfig). The combined configuration has properties in its root.
  • socket_data: A reference to the SocketData containing socket-related information.
  • error_logger: A reference to an ErrorLogger for logging errors.
§Returns

A Result containing an empty value upon success, or a boxed dyn Error if an error occurs.

Source

fn does_websocket_requests( &mut self, config: &Yaml, socket_data: &SocketData, ) -> bool

Checks if the module is a module supporting WebSocket requests.

§Parameters
  • config: A reference to the combined server configuration (ServerConfig). The combined configuration has properties in its root.
  • socket_data: A reference to the SocketData containing socket-related information.
§Returns

true if the module is a module supporting WebSocket requests, or false otherwise.

Implementors§