Function axum::routing::get

source · []
pub fn get<H, T, B>(handler: H) -> MethodRouter<B, Infallible>where
    H: Handler<T, B>,
    B: Send + 'static,
    T: 'static,
Expand description

Route GET requests to the given handler.

Example

use axum::{
    routing::get,
    Router,
};

async fn handler() {}

// Requests to `GET /` will go to `handler`.
let app = Router::new().route("/", get(handler));

Note that get routes will also be called for HEAD requests but will have the response body removed. Make sure to add explicit HEAD routes afterwards.