pub fn make_handler<F, RespBody, Err, Ret>(f: F) -> HandlerFn<F>Expand description
Creates a new handler from an async function
This function wraps an async function in a HandlerFn type that implements
the Handler trait.
§Arguments
§Examples
use micro_http::handler::make_handler;
use http::{Request, Response};
use micro_http::protocol::body::ReqBody;
use std::error::Error;
async fn my_handler(req: Request<ReqBody>) -> Result<Response<String>, Box<dyn Error + Send + Sync>> {
Ok(Response::new("Hello".to_string()))
}
let handler = make_handler(my_handler);