🦀 http-derive
Derive macro for implementing Into<http::StatusCode> for your enums using the standard http types.
Why?
- It uses the commonly-used
http::StatusCode. - Selects
http0.2 and/or 1.0 using feature flags. - Works well with other libraries like
thiserror. - Easier to define as part of an error
enuminstead of manuallyimpl From<X> for http::StatusCode.
Inspiration
Features
By default this crate enables no features. This is to allow selecting which http crate/s are selected.
If your crate has to enable http support conditionally you can leave the [#derive(HttpStatus)] in place and turn on one or more of the features below depending on your crate's feature flags.
http-1enableshttp = "1"http-02enableshttp = "0.2"
For example, in Cargo.toml add:
= { = "0.1.0", = ["http-1"] }
Examples
use HttpStatus;