Created
November 5, 2021 21:16
-
-
Save BrentMifsud/5903763e7f977030656a0dee873c2fff to your computer and use it in GitHub Desktop.
Standard HTTPMethods that can be used with URLRequests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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