Skip to content

Commit 154d93d

Browse files
committed
Fix RESTClient not using specified JSONEncoder
1 parent 02207d1 commit 154d93d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/HandySwift/Types/RESTClient.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public final class RESTClient: Sendable {
7979
}
8080
}
8181

82-
func httpData() throws -> Data {
82+
func httpData(jsonEncoder: JSONEncoder) throws -> Data {
8383
switch self {
8484
case .binary(let data):
8585
return data
8686

8787
case .json(let json):
88-
return try JSONEncoder().encode(json)
88+
return try jsonEncoder.encode(json)
8989

9090
case .string(let string):
9191
return Data(string.utf8)
@@ -164,7 +164,7 @@ public final class RESTClient: Sendable {
164164

165165
if let body {
166166
do {
167-
request.httpBody = try body.httpData()
167+
request.httpBody = try body.httpData(jsonEncoder: self.jsonEncoder)
168168
} catch {
169169
throw RequestError.failedToEncodeBody(error, self.errorContext(requestContext: errorContext))
170170
}

0 commit comments

Comments
 (0)