armature-proc-macro

Crates.ioarmature-proc-macro
lib.rsarmature-proc-macro
version0.1.1
created_at2025-12-27 00:11:38.687931+00
updated_at2025-12-30 22:24:04.260635+00
descriptionProcedural macros for Armature framework
homepagehttps://pegasusheavy.github.io/armature
repositoryhttps://github.com/pegasusheavy/armature
max_upload_size
id2006466
size103,821
Joseph R. Quinn (quinnjr)

documentation

README

armature-proc-macro

Procedural macros for the Armature framework.

This crate provides compile-time attribute macros for defining controllers, routes, and dependency injection.

Features

  • Route Macros - #[get], #[post], #[put], #[delete], #[patch]
  • Controller Macros - #[controller("/path")]
  • Module Macros - #[module(providers: [...], controllers: [...])]
  • DI Macros - #[injectable]
  • Validation - Compile-time route validation
  • Middleware - #[timeout], #[cache], #[body_limit]

Installation

[dependencies]
armature-proc-macro = "0.1"

Quick Start

use armature_proc_macro::{get, post, controller};

#[controller("/users")]
impl UserController {
    #[get("/")]
    async fn list(&self) -> Json<Vec<User>> {
        // List users
    }

    #[get("/:id")]
    async fn get(&self, id: Path<i32>) -> Json<User> {
        // Get user by ID
    }

    #[post("/")]
    async fn create(&self, body: Json<CreateUser>) -> Json<User> {
        // Create user
    }
}

Available Macros

Macro Purpose
#[controller("/path")] Define a controller with base path
#[module(...)] Define a module with providers/controllers
#[injectable] Mark a struct for dependency injection
#[get("/path")] HTTP GET route
#[post("/path")] HTTP POST route
#[put("/path")] HTTP PUT route
#[delete("/path")] HTTP DELETE route
#[patch("/path")] HTTP PATCH route
#[routes] Generate route handlers for a controller
#[timeout(ms)] Set request timeout
#[cache(ttl)] Enable response caching
#[body_limit(bytes)] Set max request body size

License

Apache-2.0

Commit count: 0

cargo fmt