Crates.io | actix_header |
lib.rs | actix_header |
version | 0.1.4 |
source | src |
created_at | 2022-09-04 09:36:28.750129 |
updated_at | 2022-09-04 15:49:18.572155 |
description | shortcut to implement actix-web headers |
homepage | |
repository | |
max_upload_size | |
id | 658207 |
size | 3,438 |
actix_header
is a shortcut to implement actix-web Header
, you only need to implement From<String>
and Into<String>
for your type, and then you can use your type in handlers directly.
example:
use actix_web::web::Header;
use actix_header::actix_header;
#[actix_header("X-CUSTOMIZED-HEADER")]
struct MyCustomizedHeader(String);
impl From<String> for MyCustomizedHeader {
fn from(s: String) -> Self {
Self(s)
}
}
impl From<MyCustomizedHeader> for String {
fn from(s: MyCustomizedHeader) -> Self {
s.0
}
}
async fn index(Header(MyCustomizedHeader(content))) -> AnyResponse {
...
}