feat: Add HTTPClient.patch() for sending PATCH requests (#15)

`PATCH` is a commonly supported verb in RESTful APIs. Although it is
already possible to send a PATCH request via the `HTTPClient.execute()`
API this commit adds an explicit `patch()` API for consistency.

This gives us explicit APIs for `GET`, `POST`, `PUT`, `PATCH` and
`DELETE`.
This commit is contained in:
Ian Partridge
2019-04-18 21:55:12 +01:00
committed by Artem Redkin
parent 15ee7ee73e
commit eda51acd9d
+9
View File
@@ -82,6 +82,15 @@ public class HTTPClient {
}
}
public func patch(url: String, body: Body? = nil, timeout: Timeout? = nil) -> EventLoopFuture<Response> {
do {
let request = try HTTPClient.Request(url: url, method: .PATCH, body: body)
return self.execute(request: request)
} catch {
return self.group.next().makeFailedFuture(error)
}
}
public func put(url: String, body: Body? = nil, timeout: Timeout? = nil) -> EventLoopFuture<Response> {
do {
let request = try HTTPClient.Request(url: url, method: .PUT, body: body)