Method
public struct Method: RawRepresentable, Equatable, Hashable
Standard HTTP Methods
-
Declaration
Swift
public private(set) var rawValue: String -
Declaration
Swift
public var hashValue: Int -
Declaration
Swift
public init(rawValue: String) -
Creates a new instance with the specified raw value.
If there is no value of the type that corresponds with the specified raw value, this initializer returns
nil. For example:enum PaperSize: String { case A4, A5, Letter, Legal } print(PaperSize(rawValue: "Legal")) // Prints "Optional("PaperSize.Legal")" print(PaperSize(rawValue: "Tabloid")) // Prints "nil"Declaration
Swift
public init?(rawValue: String?)Parameters
rawValueThe raw value to use for the new instance.
-
Creates a new instance with the specified raw value.
If there is no value of the type that corresponds with the specified raw value, this initializer returns
nil. For example:enum PaperSize: String { case A4, A5, Letter, Legal } print(PaperSize(rawValue: "Legal")) // Prints "Optional("PaperSize.Legal")" print(PaperSize(rawValue: "Tabloid")) // Prints "nil"Declaration
Swift
public init(_ rawValue: String)Parameters
rawValueThe raw value to use for the new instance.
-
The corresponding standard method string
Declaration
Swift
public var description: String
-
HTTP GET method
Declaration
Swift
public static let get = Http.Method("GET") -
HTTP PUT method
Declaration
Swift
public static let put = Http.Method("PUT") -
HTTP POST method
Declaration
Swift
public static let post = Http.Method("POST") -
HTTP DELETE method
Declaration
Swift
public static let delete = Http.Method("DELETE")
-
Returns a Boolean value indicating whether a Http.Method is equal to it’s string representation
Comparison is case insensitive. So both
Http.Method.get == "GET"andHttp.Method.get == "get"would return true.Equality is the inverse of inequality. For any values
aandb,a == bimplies thata != bisfalse.Parameters
lhsA Http.Method value to compare.
rhsA String value to compare.
-
Returns a Boolean value indicating whether a Http.Method is equal to it’s string representation
Comparison is case insensitive. So both
"GET" == Http.Method.getand"get" == Http.Method.getwould return true.Equality is the inverse of inequality. For any values
aandb,a == bimplies thata != bisfalse.Parameters
lhsA String value to compare.
rhsA Http.Method value to compare.
View on GitHub
Method Structure Reference