Poor UX when attempting to apply http-types typed headers
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
This is not very nice:
```rust
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.
```rust
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`](https://docs.rs/http-types/2.5.0/http_types/headers/trait.ToHeaderValues.html) since it would also have the header name.
@yoshuawuyts thoughts?
Contributor guide
Research direction
Start by reviewing the client's .header() API and the existing http-types ToHeaderValues trait referenced in the issue. Compare the proposed typed-header and tuple forms, then confirm that both can supply a header name and value without the current name()/value() calls; add or update coverage where the repository's header API tests live.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100