ffc5b946c24714354422b9f9e74d774186d26cd2
This PR contains automated dependency upgrades that have been tested with `cargo check` and `cargo build` ## Changes ``` name old req compatible latest new req ==== ======= ========== ====== ======= aide 0.16.0-alpha.1 0.16.0-alpha.2 0.16.0-alpha.2 0.16.0-alpha.2 anyhow 1.0.101 1.0.102 1.0.102 1.0.102 schemars 1.0 1.2.1 1.2.1 1.2 serde_json 1.0.145 1.0.149 1.0.149 1.0.149 tokio 1.48.0 1.49.0 1.49.0 1.49.0 Upgrading git dependencies [1m[32m Locking[0m 0 packages to latest Rust 1.90.0 compatible versions Upgrading recursive dependencies [1m[32m Locking[0m 0 packages to latest Rust 1.90.0 compatible versions note: Re-run with `--verbose` to show more dependencies git: axum-app-wrapper latest: 7 packages ``` ## Testing ✅ Generated test project with aide ✅ Generated test project without aide ✅ All builds passed ✅ All checks passed ## Workflow Run https://gitea.fasharp.io/fa-sharp/axum-template/actions/runs/14 --- *This PR was automatically created by the dependency check workflow.* Co-authored-by: Dependency Bot <bot@gitea.actions> Reviewed-on: #5
Axum Web Service Template
A production-ready template for building web services with Rust and Axum.
Features
- Axum - Fast and ergonomic web framework
- Configuration Management - Environment-based config with
figment - Structured Logging - JSON logging in production with
tracing - Graceful Shutdown - Handles SIGTERM and SIGINT signals
- ️Plugin Architecture - Modular app initialization with
axum-app-wrapper - Optional OpenAPI - API documentation with
aide(optional)
Usage
Using cargo-generate
Install cargo-generate if you haven't already:
cargo install cargo-generate
Generate a new project from this template:
cargo generate --git <your-template-repo-url>
You'll be prompted for:
- Project name: The name of your new project
- Project description: A brief description
- Environment variable prefix: Prefix for env vars (e.g.,
APPforAPP_HOST,APP_PORT) - Default port: The server's default port
- Default log level: trace, debug, info, warn, or error
- Include aide: Whether to include OpenAPI documentation support
Manual Setup
- Clone or download this repository
- Update
Cargo.tomlwith your project name and details - Copy
.env.exampleto.envand configure your environment variables - Run
cargo build
Configuration
Configuration is loaded from environment variables. The prefix is configurable during template generation.
Example with APP prefix:
# Required
APP_API_KEY=your-secret-key
# Optional (defaults shown)
APP_HOST=127.0.0.1
APP_PORT=8080
APP_LOG_LEVEL=info
In development, you can use the .env file.
Project Structure
.
├── src/
│ ├── main.rs # Entry point, server setup
│ ├── lib.rs # App initialization
│ ├── config.rs # Configuration management
│ └── state.rs # Application state
├── Cargo.toml # Dependencies
└── .env.example # Example environment variables
Development
# Run in development mode (loads .env file)
cargo run
# Run with custom log level
RUST_LOG=debug cargo run
# Build for production
cargo build --release
Adding Routes
This template uses axum-app-wrapper for modular initialization. To add routes:
- Create a new plugin in a separate module
- Register it in
lib.rs:
pub async fn create_app() -> anyhow::Result<(axum::Router, AppConfig, impl Future + Send)> {
let (router, state, on_shutdown) = App::new()
.register(config::plugin())
.register(your_routes::plugin()) // Add your plugin here
.init()
.await?;
let app_config = state.config.to_owned();
Ok((router.with_state(state), app_config, on_shutdown))
}
License
Configure your license as needed.
Description
Languages
Rust
62.1%
Python
21.5%
Dockerfile
8.8%
Liquid
7.6%