Skip to content

Poor UX when attempting to apply http-types typed headers #251

@Fishrock123

Description

@Fishrock123

This is not very nice:

    let authz = BasicAuth::new("any", &api_key);
    let res = client.put(&path)
        .header(authz.name(), authz.value())

(From https://github.com/squamishaccess/squamishaccess-signup-function-rs/blob/6c445916760a4db21da80c732fbe8e9c704c1bd1/src/main.rs#L168-L172)

I think something like ToHeaderPair may be ideal? We could implement that for a tuple and for typed headers.

    let authz = BasicAuth::new("any", &api_key);
    let res = client.put(&path)
        .header(authz)
        // OR
        .header((authz.name(), authz.value()))

This would be different than ToHeaderValues since it would also have the header name.

@yoshuawuyts thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions