apple / apple/swift-http-types
More convenient APIs for headers
- Dominant language
- Swift
- Stars
- 1k
- Forks
- 80
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 12
Description
Vapor supports some nice hard-typed APIs that let users interact with some header fields in a convenient manner.
For example, consider the following:
```swift
import Vapor /// `Vapor` exports `NIOHTTP1`
var headers = NIOHTTP1.HTTPHeaders()
headers.contentType = HTTPMediaType.json
```
This feature requests asks if such a feature can be supported by `swift-http-types` itself, instead of us having to implement it in each of HTTP-server packages such as Hummingbird (v2 is WIP and uses `swift-http-types`) or Vapor (in v5, the work has not yet begun but it's clear we'll be using `swift-http-types`).
My understanding is that a package like this would want to be very conservative about adding a feature like this, but I still think such convenient APIs are very valuable.
As i see it, one of the followings should be the case about this feature request, so I'm interested to know which one:
* In scope, can be supported.
* Not a main feature, maybe it can be in an e.g. `HTTPTypesExtras` target, or package.
* Completely out of scope, will not be supported.
[This is](https://github.com/vapor/vapor/blob/0680f9f6bfab7100cd585b3186740ee7860c983e/Sources/Vapor/HTTP/Headers/HTTPHeaders.swift#L5) how vapor implements such a feature for the `content-type` header.
Note that `content-type` is just an example. There could be many more header field names supported with an API like this.
Contributor guide
Research direction
Start by reviewing the existing Vapor implementation in Sources/Vapor/HTTP/Headers/HTTPHeaders.swift, especially its content-type API, and compare it with the current swift-http-types header types. The issue asks whether these convenience APIs belong in the main package, an HTTPTypesExtras target or package, or nowhere; completion therefore depends on an agreed scope and supported header fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100