Add Put & Patch methods

This commit is contained in:
Victor Bodinaud
2024-03-21 15:02:59 +01:00
parent 743530ef50
commit b29505ca1f

View File

@@ -32,6 +32,8 @@ extension NetworkError: LocalizedError {
public enum HTTPMethod {
case get([URLQueryItem])
case post(Data?)
case put(Data?)
case patch(Data?)
case delete
var name: String {
@@ -40,6 +42,10 @@ public enum HTTPMethod {
return "GET"
case .post:
return "POST"
case .put:
return "PUT"
case .patch:
return "PATCH"
case .delete:
return "DELETE"
}
@@ -88,7 +94,9 @@ public struct Hermes {
request = URLRequest(url: url)
case .post(let data):
case .post(let data),
.put(let data),
.patch(let data):
request.httpMethod = resource.method.name
request.httpBody = data