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