- New Architecture: Macro System
generate_response!: Central macro for dynamically creating customized HTTP responses. define_status!: Definition
of new status codes with their associated descriptions. response_builder!: Generation of fluid builders for
constructing complex responses.
The macro system offers increased expressiveness and flexibility while significantly reducing verbosity.
- Response Model Redesign
HttpResponse<T>: Generic structure allowing for strongly-typed response bodies. ResponseBuilder: Fluid API for
progressive construction of HTTP responses.
This redesign improves ergonomics and type safety while offering more flexibility.
- Native Integration of Asynchronous Traits
AsyncResponder: Trait allowing Futures to be returned as HTTP responses. StreamResponse: Support for streaming
response bodies for voluminous data.
The asynchronous integration optimizes performance and reduces resource consumption.
Complete documentation and new examples are available in the project's GitHub repository: (https://github.com/simbld/simbld-http/tree/main/examples)
- Macro Usage: Demonstration of response generation via the new macros.
- Fluid API: Examples of using the builder API to construct complex responses.
- Asynchronous Patterns: Integration with Rust and Actix-Web asynchronous features.
- New Feature: Unified Response Functions
invalid_date_of_birth, invalid_majority, invalid_marital_status, etc.:
Each function returns a tuple containing a status code and a description. The complete list of http codes (official and unofficial) is available in the file: (https://github.com/simbld/simbld-http/blob/main/THE_COMPLETE_LIST_OF_OFFICIAL_AND_UNOFFICIAL_HTTP_CODES.md)
- Improved Code Consistency
All response families now include functions that return a tuple (u16, &'static str) for better consistency and ease
of use.
Complete examples, including detailed use cases and advanced integrations, are available in the project's GitHub repository
https://github.com/simbld/simbld-http/tree/main/examples
https://github.com/simbld/simbld-http/blob/main/src/responses
https://github.com/simbld/simbld-http/tree/main/src/helpers
-
Http Interceptor: An.
-
Middleware Integration: Demonstration of integration into an Actix Web server with custom middleware.
-
Response Helpers: Using helpers to create responses with status codes and descriptions.
-
Actix-Web Usage: How to integrate simbld-http with Actix-Web for handling responses and authentication.
-
Unit Testing: Demonstrates how to write unit tests using the new helpers.
- New Feature: Actix-Web Integration
custom_response_handler: Generates custom HTTP responses in an Actix-Web application.
auth_middleware: Manages token validation via query parameters to secure routes.
- Improved Testing Capabilities
status_codes_test.rs: Contains tests to verify the generation of HTTP status codes.
test_helpers.rs: Provides utility functions to capture test outputs.
- New Helpers Features
mock_responses: Defines test responses to facilitate unit testing.
response_functions: Introduces the ResponseFunctions trait with methods to generate response functions.
- Miscellaneous Improvements
- Updated Documentation
- New Feature: Cookie Management
ok_with_cookie: Generate an OK response with an attached cookie.
bad_request_with_cookie: Generate a Bad Request response with an attached cookie.
- New Feature: Dynamic Headers
ok_with_headers: Generate an OK response with custom headers.
bad_request_with_headers: Generate a Bad Request response with custom headers.
- Middleware Improvement:
x-status-description: A description associated with the HTTP status code.
x-response-time-ms: The request processing time in milliseconds.
Complete examples, including detailed use cases and advanced integrations, are available in the project's GitHub repository (https://github.com/simbld/simbld-http/tree/main/examples).
-
Basic Usage: An introduction to using simbld-http.
-
Middleware Integration: Demonstration of integration into an Actix Web server with custom middleware.
-
Response Helpers: Using helpers to create responses with cookies or custom headers.
simbld-http is a modular and comprehensive Rust library designed for managing HTTP response codes. Whether
you're building APIs, handling custom response codes, or integrating middleware, Simbld-HTTP provides an organized and
extensible framework to simplify your workflow.
Support for Standard and Custom HTTP Codes:
Handles all standard HTTP response families: 1xx to 5xx. Extends with custom families: 6xx, 7xx, and 9xx. Includes detailed descriptions for every status code.
Extensive Utilities:
JSON and XML response formatting. Helpers for paginated and generic HTTP responses. Middleware integration for Actix Web.
Easy Extensibility:
Add new families or custom helpers with minimal effort.
Developer-Friendly: Intuitive API with detailed documentation. Modular Design: Use only the parts you need for your project. Future-Proof: Easily extend to accommodate evolving HTTP standards and custom needs. Battle-Tested: Includes robust tests to ensure reliability.
Add simbld-http to your ``Cargo.toml:
[dependencies]
simbld-http = "0.2.0"
Run the following command to generate and open the documentation:
cargo doc --no-deps --open- Generate detailed API documentation from inline comments (///).
- Display all public modules, enums, and methods.
The full documentation will be available on docs.rs after publishing. Stay tuned for updates!
use simbld_http::responses::ResponsesTypes;
let response = ResponsesTypes::Success(ResponsesSuccessCodes::Ok);
println!("Code: {}, Description: {}", response.get_code(), response.get_str("Description"));use simbld_http::responses::ResponsesCrawlerCodes;
use strum::EnumProperty;
fn main() {
let code = ResponsesCrawlerCodes::ParsingErrorHeader;
println!(
"Code: {}, Description: {}",
code.get_code(),
code.get_str("Description").unwrap()
);
}
cargo run --example examples_usagecargo run --example middleware_advanced_usagecurl -i http://127.0.0.1:8080/| Family | Description |
|---|---|
| 1xx | Informational responses (e.g., ContinueRequest, Processing) |
| 2xx | Success responses (e.g., OK, Created) |
| 3xx | Redirection responses (e.g., Moved Permanently, Temporary Redirect) |
| 4xx | Client errors (e.g., Bad Request, Unauthorized) |
| 5xx | Server errors (e.g., Internal Server Error, Service Unavailable) |
| 6xx | Service operations (e.g., Service Timeout) |
| 7xx | Crawler responses (e.g., Rate Limited, Crawl Blocked) |
| 9xx | Local API errors (e.g., InsufficientFunds, ExpiredCard) |
We welcome contributions to Simbld-HTTP! Help us make this library the go-to solution for HTTP response code management in Rust.
git clone git@github.com:<your-username>/simbld-http.git
git switch -c feature/<your-feature-name>
cargo test
This project is licensed under the MIT License. See the LICENSE file for details.