Skip to content

Instantly share code, notes, and snippets.

@BrentMifsud
Created November 5, 2021 21:16
Show Gist options
  • Save BrentMifsud/5903763e7f977030656a0dee873c2fff to your computer and use it in GitHub Desktop.
Save BrentMifsud/5903763e7f977030656a0dee873c2fff to your computer and use it in GitHub Desktop.
Standard HTTPMethods that can be used with URLRequests
import Foundation
/// Standard HTTP Methods
enum HTTPMethod: String {
case options = "OPTIONS"
case get = "GET"
case head = "HEAD"
case post = "POST"
case put = "PUT"
case patch = "PATCH"
case delete = "DELETE"
case trace = "TRACE"
case connect = "CONNECT"
}
extension URLRequest {
/// Set the `URLRequest` httpMethod property with an `HTTPMethod` enum
/// - Parameter httpMethod: The HTTPMethod
mutating func setHttpMethod(_ httpMethod: HTTPMethod) {
self.httpMethod = httpMethod.rawValue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment