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§
Sourcefn 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 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
: ARequestData
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 theSocketData
containing socket-related information.error_logger
: A reference to anErrorLogger
for logging errors.
§Returns
A Result
containing a ResponseData
object upon success, or a boxed dyn Error
if an error occurs.
Sourcefn 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 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
: ARequestData
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 theSocketData
containing socket-related information.error_logger
: A reference to anErrorLogger
for logging errors.
§Returns
A Result
containing a ResponseData
object upon success, or a boxed dyn Error
if an error occurs.
Sourcefn 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 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
: AHyperResponse
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.
Sourcefn 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 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
: AHyperResponse
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.
Sourcefn 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 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
: AHyperUpgraded
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 theSocketData
containing socket-related information.error_logger
: A reference to anErrorLogger
for logging errors.
§Returns
A Result
containing an empty value upon success, or a boxed dyn Error
if an error occurs.
Sourcefn does_connect_proxy_requests(&mut self) -> bool
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.
Sourcefn 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 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
: AHyperWebsocket
object containing a future that resolves to a WebSocket stream.uri
: Ahyper::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 theSocketData
containing socket-related information.error_logger
: A reference to anErrorLogger
for logging errors.
§Returns
A Result
containing an empty value upon success, or a boxed dyn Error
if an error occurs.
Sourcefn does_websocket_requests(
&mut self,
config: &Yaml,
socket_data: &SocketData,
) -> bool
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 theSocketData
containing socket-related information.
§Returns
true
if the module is a module supporting WebSocket requests, or false
otherwise.