#axum #routing #controller #macro #handler

macro axum-folder-router

Helper macro for simple folder based routing of axum handlers

9 releases

Uses new Rust 2024

new 0.3.3 Apr 15, 2025
0.3.2 Apr 15, 2025
0.2.3 Apr 14, 2025
0.1.0 Apr 14, 2025

#1206 in Web programming

Download history 245/week @ 2025-04-08

270 downloads per month

MIT license

21KB
318 lines

Crates.io Documentation Maintenance License: MIT

axum-folder-router

#[folder_router(...)] is a procedural attribute macro for the Axum web framework that automatically generates router boilerplate based on your direcory & file structure. Inspired by popular frameworks like next.js.

Features

  • File System-Based Routing: Define your API routes using intuitive folder structures
  • Reduced Boilerplate: Automatically generates route mapping code
  • IDE Support: Generates proper module imports for better rust-analyzer integration
  • Multiple Routers: Create separate folder-based routers in the same application

Usage

For detailed instructions see the examples or docs.rs.

License

This repository, is licensed permissively under the terms of the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.

Attribution

This macro is based on the build.rs template by @richardanaya

Dependencies

~4–6.5MB
~119K SLoC