Axum Service Skill
Idiomatic Axum 0.8 web-service generation and review - an Agent Skill for Rust 1.97.0, Tokio 1.x, and serde 1.0.
Busca en todas las páginas de la documentación
Idiomatic Axum 0.8 web-service generation and review - an Agent Skill for Rust 1.97.0, Tokio 1.x, and serde 1.0.
Produces a deployable HTTP service checklist: workspace Cargo.toml, Router modules, shared AppState (PgPool, reqwest::Client), /health and /ready, tracing subscriber, thiserror domain errors mapped to status codes, and integration tests with tower::ServiceExt.
| Input | Why |
|---|---|
| Service name | Crate name, log fields, image tag |
| DB required? | sqlx::PgPool in state vs stub |
| Auth model | None, API key header, JWT middleware |
| Port | Default 3000 or platform convention |
| Workspace path | services/billing-api vs root crate |
Cargo.toml with axum, tokio, tower-http, tracing, serde, optional sqlxsrc/main.rs with TcpListener, graceful shutdownsrc/routes/mod.rs, health.rs, domain routerssrc/error.rs with IntoResponse mappingtests/health.rs using oneshot requestsspawn_blocking or async DB only..env.example placeholders only.tracing - #[instrument] on handlers; no println! in prod paths.Arc<PgPool> and reused reqwest::Client.cd services/billing-api
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test
cargo run &
curl -sf http://localhost:3000/health
curl -sf http://localhost:3000/readyuse axum::{routing::get, Router};
use std::net::SocketAddr;
use tokio::net::TcpListener;
mod routes;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init();
let app = Router::new()
.merge(routes::health::router());
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
let listener = TcpListener::bind(addr).await?;
axum::serve(listener, app).await?;
Ok(())
}Axum when team standard is Tokio + Tower ecosystem. Actix only when ADR already selects it.
Only when input specifies GraphQL day one; default REST routers.
Add utoipa in follow-up PR after routes stabilize.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Revisado por Chris St. John·Última actualización: 16 jul 2026