Skip to main content

app

Function app 

Source
pub fn app() -> Router
Expand description

Generator of the program’s router. Exposed publicly for integration with other axum-based programs.

Exposes the “/v1/{format}” route, such that {format} is one of the supported formats.

§Crate Features

With utoipa-swagger-ui enabled, it also exposes the “/docs” route for the Swagger UI of the API.

§Examples: Adding it as an API to another program through nesting

use axum::{routing::get, Router};
use tokio::net::TcpListener;

let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap();
let api_router = any2nix_api::app();
let app = Router::new().route("/", get(|| async { "Hello, World!"})).nest("/api", api_router);

axum::serve(listener, app).await.unwrap();