Function axum::routing::method_routing::get

source ·
pub fn get<H, T, S, B>(handler: H) -> MethodRouter<S, B, Infallible>
where H: Handler<T, S, B>, B: HttpBody + Send + 'static, T: 'static, S: Clone + Send + Sync + '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.