Crate armature_macros

Crate armature_macros 

Source
Expand description

Declarative macros for the Armature framework

This crate provides convenient declarative macros (macro_rules!) for common patterns in Armature applications.

§Response Macros

Quick HTTP responses:

json_response!({ "message": "Success" })
ok_json!({ "id": 123 })
error_json!("User not found")

§Route Grouping

routes! {
    GET "/users" => list_users,
    POST "/users" => create_user,
    GET "/users/:id" => get_user,
}

Modules§

prelude
Prelude module for common macro imports

Macros§

bad_request
Create a 400 Bad Request JSON error response
created_json
Create a 201 Created JSON response
guard
Guard a condition, returning an error if false
header
Extract header value
internal_error
Create a 500 Internal Server Error JSON response
json_object
Build JSON objects with type safety
json_response
Create a JSON HTTP response with status code
log_error
Log and return an error
not_found
Create a 404 Not Found JSON error response
ok_json
Create a 200 OK JSON response
paginated_response
Create a paginated response
path_param
Extract and validate path parameters
path_params
Extract multiple path params at once
query_param
Extract and validate query parameters
routes
Define multiple routes concisely
validation_error
Create a validation error