into_handler

Function into_handler 

Source
pub fn into_handler<H, T>(handler: H) -> HandlerFn
where H: IntoHandler<T>,
Expand description

Converts an IntoHandler into a HandlerFn.

This function bridges the gap between the type-safe IntoHandler system and the runtime HandlerFn type used by the routing system.

§Type Parameters

  • H: The handler type that implements IntoHandler
  • T: The tuple of extractor types

§Parameters

  • handler: The handler to convert

§Returns

A HandlerFn that can be used with the router

§Examples

use ignitia::{into_handler, Router, Response, Result};

async fn hello_handler() -> Result<Response> {
    Ok(Response::text("Hello World!"))
}

let router = Router::new()
    .route("/hello", http::Method::GET, into_handler(hello_handler));

Note: In most cases, you won’t need to call this function directly as the router methods (.get(), .post(), etc.) handle the conversion automatically.