Function webhook_flows::route::route

source ·
pub async fn route(
    router: Router<Vec<(Method, Box<dyn Fn(Vec<(String, String)>, HashMap<String, Value>, Vec<u8>) -> Pin<Box<dyn Future<Output = ()>>>>)>>
) -> Result<(), RouteError>
Expand description

Route path to handler. For calling the exact handler, construct the router then pass it to this function.

let mut router = Router::new();
router
    .insert("/options", vec![options(opt)])
    .unwrap();
router
    .insert(
        "/get/:city",
        vec![options(opt), get(query)],
    )
    .unwrap();
if let Err(e) = route(router).await {
    send_response(404, vec![], b"No route matched".to_vec())
}