#header #actix-web #shortcut

macro actix_header

shortcut to implement actix-web headers

1 unstable release

0.1.4 Sep 4, 2022
0.1.3 Sep 4, 2022
0.1.2 Sep 4, 2022
0.1.1 Sep 4, 2022
0.1.0 Sep 4, 2022

#16 in #shortcut

MIT license

4KB

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 {
        ...
    }

Dependencies

~1.5MB
~36K SLoC