mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
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:
committed by
Artem Redkin
parent
15ee7ee73e
commit
eda51acd9d
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user