0001 /* 0002 The MIT License (MIT) 0003 0004 Copyright (c) 2015 Shun Takebayashi 0005 0006 Permission is hereby granted, free of charge, to any person obtaining a copy 0007 of this software and associated documentation files (the "Software"), to deal 0008 in the Software without restriction, including without limitation the rights 0009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0010 copies of the Software, and to permit persons to whom the Software is 0011 furnished to do so, subject to the following conditions: 0012 0013 The above copyright notice and this permission notice shall be included in all 0014 copies or substantial portions of the Software. 0015 0016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0019 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0020 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0021 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 0022 SOFTWARE. 0023 */ 0024 0025 public struct Response{ 0026 0027 public enum Status
Response.swift:91 extension Response.Status: CustomStringConvertible {ResponseSource.swift:27 func response() -> ResponseResponseSource.swift:31 extension Response: ResponseSource {ResponseSource.swift:33 public func response() -> Response {ResponseSource.swift:41 public func response() -> Response {ResponseSource.swift:42 return Response(self)Router.swift:36 func dispatch(request: Request) -> Response? {: Int { 0028 case Continue
Response.swift:71 var status = Status.OKResponse.swift:75 public init(status: Status, headers: [String: String], body: String) {Response.swift:85 public init(_ status: Status) {Response.swift:91 extension Response.Status: CustomStringConvertible {= 100 0029 case SwitchingProtocols
Response.swift:95 case Continue:= 101 0030 case OK
Response.swift:97 case SwitchingProtocols:= 200 0031 case Created
Response.swift:71 var status = Status.OKResponse.swift:99 case OK:= 201 0032 case Accepted
Response.swift:101 case Created:= 202 0033 case NonAuthoritativeInformation
Response.swift:103 case Accepted:= 203 0034 case NoContent
Response.swift:105 case NonAuthoritativeInformation:= 204 0035 case ResetContent
Response.swift:107 case NoContent:= 205 0036 case PartialContent
Response.swift:109 case ResetContent:= 206 0037 case MultipleChoices
Response.swift:111 case PartialContent:= 300 0038 case MovedPermanently
Response.swift:113 case MultipleChoices:= 301 0039 case Found
Response.swift:115 case MovedPermanently:= 302 0040 case SeeOther
Response.swift:117 case Found:= 303 0041 case NotModified
Response.swift:119 case SeeOther:= 304 0042 case UseProxy
Response.swift:121 case NotModified:= 305 0043 case TemporaryRedirect
Response.swift:123 case UseProxy:= 307 0044 case BadRequest
Response.swift:125 case TemporaryRedirect:= 400 0045 case Unauthorized
Response.swift:127 case BadRequest:= 401 0046 case PaymentRequired
Response.swift:129 case Unauthorized:= 402 0047 case Forbidden
Response.swift:131 case PaymentRequired:= 403 0048 case NotFound
Response.swift:133 case Forbidden:= 404 0049 case MethodNotAllowed
Response.swift:135 case NotFound:= 405 0050 case NotAcceptable
Response.swift:137 case MethodNotAllowed:= 406 0051 case ProxyAuthenticationRequired
Response.swift:139 case NotAcceptable:= 407 0052 case RequestTimeout
Response.swift:141 case ProxyAuthenticationRequired:= 408 0053 case Conflict
Response.swift:143 case RequestTimeout:= 409 0054 case Gone
Response.swift:145 case Conflict:= 410 0055 case LengthRequired
Response.swift:147 case Gone:= 411 0056 case PreconditionFailed
Response.swift:149 case LengthRequired:= 412 0057 case RequestEntityTooLarge
Response.swift:151 case PreconditionFailed:= 413 0058 case RequestURITooLong
Response.swift:153 case RequestEntityTooLarge:= 414 0059 case UnsupportedMediaType
Response.swift:155 case RequestURITooLong:= 415 0060 case RequestedRangeNotSatisfiable
Response.swift:157 case UnsupportedMediaType:= 416 0061 case ExpectationFailed
Response.swift:159 case RequestedRangeNotSatisfiable:= 417 0062 case UnavailableForLegalReasons
Response.swift:161 case ExpectationFailed:= 451 0063 case InternalServerError
Response.swift:163 case UnavailableForLegalReasons:= 500 0064 case NotImplemented
Response.swift:165 case InternalServerError:= 501 0065 case BadGateway
Response.swift:167 case NotImplemented:= 502 0066 case ServiceUnavailable
Response.swift:169 case BadGateway:= 503 0067 case GatewayTimeout
Response.swift:171 case ServiceUnavailable:= 504 0068 case HTTPVersionNotSupported
Response.swift:173 case GatewayTimeout:= 505 0069 } 0070 0071 var status
Response.swift:175 case HTTPVersionNotSupported:= Status.OK 0072 var headers
Response.swift:76 self.status = statusResponse.swift:86 self.status = status= [String: String]() 0073 var body
Response.swift:77 self.headers = headers= [Int8]() 0074 0075 public init(status: Status, headers: [String: String], body: String) { 0076 self.status = status 0077 self.headers = headers 0078 self.body = body.bytes() 0079 } 0080 0081 public init
Response.swift:78 self.body = body.bytes()Response.swift:82 self.body = content.bytes()(_ content: String) { 0082 self.body = content.bytes() 0083 } 0084 0085 public init(_ status: Status) { 0086 self.status = status 0087 } 0088 0089 } 0090 0091 extension Response.Status: CustomStringConvertible { 0092 0093 public var description: String { 0094 switch self { 0095 case Continue: 0096 return "Continue" 0097 case SwitchingProtocols: 0098 return "Switching Protocols" 0099 case OK: 0100 return "OK" 0101 case Created: 0102 return "Created" 0103 case Accepted: 0104 return "Accepted" 0105 case NonAuthoritativeInformation: 0106 return "Non-Authoritative Information" 0107 case NoContent: 0108 return "No Content" 0109 case ResetContent: 0110 return "Reset Content" 0111 case PartialContent: 0112 return "Partial Content" 0113 case MultipleChoices: 0114 return "Multiple Choices" 0115 case MovedPermanently: 0116 return "Moved Permanently" 0117 case Found: 0118 return "Found" 0119 case SeeOther: 0120 return "See Other" 0121 case NotModified: 0122 return "Not Modified" 0123 case UseProxy: 0124 return "Use Proxy" 0125 case TemporaryRedirect: 0126 return "Temporary Redirect" 0127 case BadRequest: 0128 return "Bad Request" 0129 case Unauthorized: 0130 return "Unauthorized" 0131 case PaymentRequired: 0132 return "Payment Required" 0133 case Forbidden: 0134 return "Forbidden" 0135 case NotFound: 0136 return "Not Found" 0137 case MethodNotAllowed: 0138 return "Method Not Allowed" 0139 case NotAcceptable: 0140 return "Not Acceptable" 0141 case ProxyAuthenticationRequired: 0142 return "Proxy Authentication Required" 0143 case RequestTimeout: 0144 return "Request Timeout" 0145 case Conflict: 0146 return "Conflict" 0147 case Gone: 0148 return "Gone" 0149 case LengthRequired: 0150 return "Length Required" 0151 case PreconditionFailed: 0152 return "Precondition Failed" 0153 case RequestEntityTooLarge: 0154 return "Request Entity Too Large" 0155 case RequestURITooLong: 0156 return "Request-URI Too Long" 0157 case UnsupportedMediaType: 0158 return "Unsupported Media Type" 0159 case RequestedRangeNotSatisfiable: 0160 return "Requested Range Not Satisfiable" 0161 case ExpectationFailed: 0162 return "Expectation Failed" 0163 case UnavailableForLegalReasons: 0164 return "Unavailable For Legal Reasons" 0165 case InternalServerError: 0166 return "Internal Server Error" 0167 case NotImplemented: 0168 return "Not Implemented" 0169 case BadGateway: 0170 return "Bad Gateway" 0171 case ServiceUnavailable: 0172 return "Service Unavailable" 0173 case GatewayTimeout: 0174 return "Gateway Timeout" 0175 case HTTPVersionNotSupported: 0176 return "HTTP Version Not Supported" 0177 } 0178 } 0179 0180 } 0181
ResponseSource.swift:42 return Response(self)