Skip to content

Commit

Permalink
fix(request): Fixed delete request missing body (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjechris authored Nov 24, 2022
1 parent 20b9a74 commit 79e1655
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/SimpleHTTP/Request/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public struct Request<Output> {

/// Creates a DELETE request with a Encodable body
public static func delete(_ path: Path, body: Encodable, query: [String: QueryParam] = [:]) -> Self {
self.init(path: path, method: .delete, query: query, body: nil)
self.init(path: path, method: .delete, query: query, body: .encodable(body))
}

/// Creates a Request.
Expand Down
5 changes: 5 additions & 0 deletions Tests/SimpleHTTPTests/Request/RequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ class RequestTests: XCTestCase {
)
}

func test_initDelete_withBody_returnRequestWithBody() {
let request = Request<Void>.delete("", body: BodyMock())

XCTAssertNotNil(request.body)
}
}

private struct BodyMock: Encodable {
Expand Down

0 comments on commit 79e1655

Please sign in to comment.