Closed
Description
I believe that the community would benefit from adding a simple boolean check whether the status code of the response is acceptable.
I took inspiration from the javascript's fetch
API where the response exposes response.ok
to check whether the status code is >= 200 and < 300 (see the documentation), and created a simple extension to make my life easier.
extension HTTPClientResponse {
var isOk: Bool {
status.code >= 200 && status.code < 300
}
}
Happy to contribute (and write tests) this if there is interest from the side of the maintainers.
Metadata
Metadata
Assignees
Labels
No labels