Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Axum Params
A powerful parameter handling library for Axum web framework, inspired by Ruby on Rails' parameter system. Seamlessly handles multiple parameter sources and tree-structured data with file uploads.
Features
-
Unified Parameter Handling
- Path parameters
- Query parameters
- Form data
- Multipart form data
- JSON body
- All parameter types can be processed simultaneously
- Every parameter type supports structured data (arrays and objects)
-
Rails-like Tree-Structured Parameters
- Nested parameter handling similar to Rails' strong parameters
- Support for deeply nested structures with arrays and objects
- Files can be placed at any position in the parameter tree, e.g.
post[attachments][][file]
- Seamlessly mix files with other data types in the same request
- Automatic parameter parsing and type conversion
- Handle complex forms with multiple file uploads in nested structures
Example structure:
post: >
}
Installation
Add this to your Cargo.toml
:
[]
= "0.4"
Quick Start
use ;
use Params;
use ;
async
Rails-like Parameter Structure
Just like Rails, you can send nested parameters in various formats:
Combined Parameters Example
# Combining path parameters, query parameters, and form data
JSON Body
# Sending JSON data (note: file uploads not possible in pure JSON)
Form Data
# Basic form data with nested parameters and file uploads
Multipart Form
The library automatically handles multipart form data, allowing you to upload files within nested structures. Files can be placed at any level in the parameter tree, and you can combine them with regular form fields.
# Complex multipart form matching the Post struct example
This example demonstrates how the multipart form maps to the Rust struct:
- Single field (
title
,content
) - Array field (
tags[]
) - Single file field (
cover
) - Nested array with files (
attachments[]
withfile
anddescription
)
Examples
- Basic Parameters - Handling path, query, and JSON parameters
- File Upload - Basic file upload with metadata
- Nested Parameters - Complex nested structures with multiple file uploads
Running Examples
# Run basic parameters example
# Run file upload example
# Run nested parameters example
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- The parameter parsing implementation is ported from Rack's QueryParser, which provides robust and battle-tested parameter parsing capabilities.
- This project draws inspiration from Ruby on Rails' parameter handling system, adapting its elegant approach to parameter processing for the Rust and Axum ecosystem.
License
This project is licensed under the MIT License - see the LICENSE file for details.