mirror of
https://github.com/samsonjs/Osiris.git
synced 2026-03-25 08:55:48 +00:00
This introduces a cleaner, more intuitive API for making HTTP requests
with explicit methods for different content types and built-in Codable
support.
**New**
- Add explicit request methods: .postJSON(), .postForm(),
.postMultipart() for clear intent
- Add direct `Codable` body support with automatic JSON
encoding/decoding
- Add `HTTPRequestBody` enum for internal type safety and cleaner
implementation
- Add proper query parameter encoding for GET and DELETE requests
(previously ignored)
- Add URLSession extensions for streamlined async JSON decoding with
`HTTPError` for failure response status codes
- Add comprehensive test coverage
The new API replaces the parameter-based methods using dictionaries with
explicitly-typed ones. Instead of passing a content-type parameter, you
now use purpose-built methods like `postJSON` and `postForm`.
**Breaking changes**
- Minimum deployment targets raised to iOS 16.0 and macOS 13.0
- Direct access to `parameters` and `parts` properties deprecated on
`HTTPRequest`
- GET and DELETE requests now validate that they don't have request
bodies, and the new API prevents you from constructing them
3.2 KiB
3.2 KiB
Changelog
2.1.0 - Unreleased
Added
- Codable body support in HTTPRequest factory methods:
post(body:encoder:),put(body:encoder:),patch(body:encoder:) - URLSession extensions for automatic JSON decoding with custom decoder support
- HTTPError type with status code and response body for better error debugging
- Multipart convenience methods:
postMultipart(),putMultipart(),patchMultipart() - Explicit body encoding methods with clear naming:
postJSON(),postForm(), etc. - Query parameter support for GET and DELETE requests - parameters are now properly encoded as query strings
Removed
CodableRequest<Response>- Replaced with direct HTTPRequest Codable support for simplicity
Changed
- Minimum deployment targets changed to ones that actually build: iOS 16.0 and macOS 13.0
HTTPRequestnow usesHTTPRequestBodyenum internally for better type safety- GET and DELETE requests now properly encode parameters as query strings instead of ignoring them
- Added validation to prevent GET/DELETE requests from having request bodies
Deprecated
HTTPRequest.post(url:contentType:parameters:)- UsepostJSON()orpostForm()insteadHTTPRequest.put(url:contentType:parameters:)- UseputJSON()orputForm()insteadHTTPRequest.patch(url:contentType:parameters:)- UsepatchJSON()orpatchForm()instead- Direct access to
HTTPRequest.parametersproperty - Direct access to
HTTPRequest.partsproperty
Migration Guide
- Swap
HTTPRequest.post(url, contentType: .json, parameters: params)forHTTPRequest.postJSON(url, body: params) - Swap
HTTPRequest.post(url, contentType: .formEncoded, parameters: params)forHTTPRequest.postForm(url, parameters: params) - Swap
HTTPRequest.put(url, contentType: .json, parameters: params)forHTTPRequest.putJSON(url, body: params) - Swap
HTTPRequest.patch(url, contentType: .json, parameters: params)forHTTPRequest.patchJSON(url, body: params) - For multipart requests, use
HTTPRequest.postMultipart(url, parts: parts)instead of setting thepartsproperty directly
2.0.1 - 2025-06-15
Fixed
- GET and DELETE requests with empty parameters no longer include unnecessary question mark in URL
2.0.0 - 2025-06-15
Added
- GET/DELETE query parameter support - Parameters are now automatically encoded as query strings for GET and DELETE requests
- Enhanced error types with localized descriptions and failure reasons
- Comprehensive test coverage
Enhanced
- Public API - All types and methods now have proper public access modifiers
- Error handling - More specific error cases with
LocalizedErrorconformance - Debugging support - All types now conform to
CustomStringConvertiblewith idiomatic descriptions for better OSLog output
1.0.0 - 2017-07-28
Added
- Initial release with multipart form encoding
- HTTPRequest and HTTPResponse abstractions
- RequestBuilder for URLRequest conversion
- FormEncoder for URL-encoded forms