Skip to content

Commit

Permalink
Fix RESTClient not using specified JSONEncoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Nov 24, 2024
1 parent 02207d1 commit 154d93d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/HandySwift/Types/RESTClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ public final class RESTClient: Sendable {
}
}

func httpData() throws -> Data {
func httpData(jsonEncoder: JSONEncoder) throws -> Data {
switch self {
case .binary(let data):
return data

case .json(let json):
return try JSONEncoder().encode(json)
return try jsonEncoder.encode(json)

case .string(let string):
return Data(string.utf8)
Expand Down Expand Up @@ -164,7 +164,7 @@ public final class RESTClient: Sendable {

if let body {
do {
request.httpBody = try body.httpData()
request.httpBody = try body.httpData(jsonEncoder: self.jsonEncoder)
} catch {
throw RequestError.failedToEncodeBody(error, self.errorContext(requestContext: errorContext))
}
Expand Down

0 comments on commit 154d93d

Please sign in to comment.