@rulepack/rust-axum

v0.1.3

Idiomatic axum 0.8 service rules: layered tower, tracing, thiserror, sqlx, async-first.

Updated 6/4/20265 files | 3.9 KB
$pnpm dlx rulepack add rust-axum

Drops CLAUDE.md / .cursor/rules/* and friends into your project.

Downloads

0

Stars

0

Views

0

rust-axum

Idiomatic axum 0.8 service rules: layered tower, tracing, thiserror, sqlx, async-first.

npx rulepack add rust-axum

What it covers

  • Routing: Router::new() per module composed at main, no global mutable state, and axum::extract types (State, Path, Query, Json) over manual deserialisation
  • Handlers return Result<impl IntoResponse, AppError> with AppError: IntoResponse
  • Tower layers at the root: tower_http::trace::TraceLayer and tower_http::cors::CorsLayer
  • Errors: one thiserror enum whose variants map to HTTP status codes via IntoResponse; anyhow confined to bin/example crates
  • Async & state: tokio runtime, no blocking I/O in async fns (spawn_blocking when needed), connections held in a cloneable Arc-backed AppState
  • Database: sqlx with the postgres feature, compile-time-checked sqlx::query!, migrations under migrations/ via sqlx-cli

Source

Rules align with the official axum documentation: https://docs.rs/axum/latest/axum/

License

MIT