commit 219cdb37a5b7663dbb62c636b4151d67df50ccdf parent bc107305ea1fdc81f5b512297a909c162a0b911f Author: FIGBERT <figbert@figbert.com> Date: Sun, 24 Jul 2022 14:44:51 -0700 Make StatusCode interface more ergonomic Diffstat:
M | Sources/SwiftGemini/StatusCode.swift | | | 57 | ++++++++++++++++++++++++++++++++++++++++----------------- |
1 file changed, 40 insertions(+), 17 deletions(-)
diff --git a/Sources/SwiftGemini/StatusCode.swift b/Sources/SwiftGemini/StatusCode.swift @@ -1,22 +1,45 @@ import Foundation enum StatusCode: Int { - case Input = 10 - case SensitiveInput = 11 - case Success = 20 - case TemporaryRedirect = 30 - case PermanentRedirect = 31 - case TemporaryFailure = 40 - case ServerUnavailable = 41 - case CGIError = 42 - case ProxyError = 43 - case SlowDown = 44 - case PermanentFailure = 50 - case NotFound = 51 - case Gone = 52 + case Input = 10 + case SensitiveInput = 11 + case Success = 20 + case TemporaryRedirect = 30 + case PermanentRedirect = 31 + case TemporaryFailure = 40 + case ServerUnavailable = 41 + case CGIError = 42 + case ProxyError = 43 + case SlowDown = 44 + case PermanentFailure = 50 + case NotFound = 51 + case Gone = 52 case ProxyRequestRefused = 53 - case BadRequest = 59 - case ClientCertRequired = 60 - case ClientCertNotAuth = 61 - case ClientCertNotValid = 62 + case BadRequest = 59 + case ClientCertRequired = 60 + case ClientCertNotAuth = 61 + case ClientCertNotValid = 62 + + var description: String { + switch self { + case .Input: return "Input" + case .SensitiveInput: return "Sensitive Input" + case .Success: return "Success" + case .TemporaryRedirect: return "Redirect - Temporary" + case .PermanentRedirect: return "Redirect - Permanent" + case .TemporaryFailure: return "Temporary Failure" + case .ServerUnavailable: return "Server Unavailable" + case .CGIError: return "CGI Error" + case .ProxyError: return "Proxy Error" + case .SlowDown: return "Slow Down" + case .PermanentFailure: return "Permanent Failure" + case .NotFound: return "Not Found" + case .Gone: return "Gone" + case .ProxyRequestRefused: return "Proxy Request Refused" + case .BadRequest: return "Bad Request" + case .ClientCertRequired: return "Client Certificate Required" + case .ClientCertNotAuth: return "Client Certificate Not Authorized" + case .ClientCertNotValid: return "Client Certificate Not Valid" + } + } }