9 unstable releases (3 breaking)
0.3.2 | Oct 25, 2023 |
---|---|
0.3.1 | Oct 17, 2023 |
0.2.1 | Aug 27, 2023 |
0.2.0 | May 14, 2023 |
0.0.2 | Mar 8, 2023 |
#415 in Procedural macros
78 downloads per month
6KB
91 lines
Derive for creating easy http api errors
Example
use http_error_derive::HttpError;
#[derive(HttpError)]
enum ApiError {
#[http(code = 401, message = "You must be logged in to access this resource")]
Unauthorized,
#[http(code = 403, message = "You have no permission to access this resource")]
Forbidden,
}
fn main() {
println!("{}", ApiError::Forbidden.http_code()); // Some(403u16)
println!("{:?}", ApiError::Forbidden.http_message()); // Some("You have no permission to access this resource")
}
Dependencies
~0.6–1MB
~23K SLoC