HandlerFunction

Type Alias HandlerFunction 

Source
pub type HandlerFunction = fn(HTTPRequest, Arc<RwLock<Args>>) -> Result<HTTPResponse>;
Expand description

A type alias for a function that handles HTTP requests.

This function takes an HTTPRequest and an Arc<RwLock<Args>> as parameters, and returns a result containing an HTTPResponse. It is used to define the structure of handler functions that can process HTTP requests.

§Parameters

  • request: An instance of HTTPRequest that represents the incoming HTTP request.
  • args: An Arc<RwLock<Args>> containing additional arguments that can be accessed and modified safely across multiple threads.

§Returns

An anyhow::Result<HTTPResponse>, which indicates the success or failure of the request handling. On success, it returns an HTTPResponse, and on failure, it returns an error wrapped in anyhow::Error.