StatusCode
public struct StatusCode: RawRepresentable, Equatable, Hashable
HTTP Status Codes
See also
HTTP/1.1: Status Code Definitions-
Declaration
Swift
public private(set) var rawValue: Int
-
Declaration
Swift
public var hashValue: Int
-
Declaration
Swift
public init(rawValue: Int)
-
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: Int)
Parameters
rawValue
The raw value to use for the new instance.
-
Status code 200: OK
Declaration
Swift
public static let ok = Http.StatusCode(200)
-
Status code 201: Created
Declaration
Swift
public static let created = Http.StatusCode(201)
-
Status code 302: Found
Declaration
Swift
public static let found = Http.StatusCode(302)
-
Status code 307: Temporary Redirect
Declaration
Swift
public static let temporaryRedirect = Http.StatusCode(307)
-
Status code 400: Bad Request
Declaration
Swift
public static let badRequest = Http.StatusCode(400)
-
Status code 401: Unauthorized
Declaration
Swift
public static let unauthorized = Http.StatusCode(401)
-
Status code 403: Forbidden
Declaration
Swift
public static let forbidden = Http.StatusCode(403)
-
Status code 404: Not Found
Declaration
Swift
public static let notFound = Http.StatusCode(404)
-
Status code 405: Method Not Allowed
Declaration
Swift
public static let methodNotAllowed = Http.StatusCode(405)
-
Status code 409: Conflict
Declaration
Swift
public static let conflict = Http.StatusCode(409)
-
Status code 500: Internal Server Error
Declaration
Swift
public static let internalServerError = Http.StatusCode(500)
-
Status code 501: Not Implemented
Declaration
Swift
public static let notImplemented = Http.StatusCode(501)
-
Status code 504: Gateway Timeout
Declaration
Swift
public static let gatewayTimeout = Http.StatusCode(504)
-
Status code 505: Not Supported
Declaration
Swift
public static let notSupported = Http.StatusCode(505)
-
Returns a Boolean value indicating whether a StatusCode is equal to it’s Int representation
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.Declaration
Parameters
lhs
A Http.StatusCode value to compare.
rhs
A Int value to compare.
-
Returns a Boolean value indicating whether a StatusCode is equal to it’s Int representation
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.Declaration
Parameters
lhs
A Int value to compare.
rhs
A Http.StatusCode value to compare.