25 lines
912 B
Go
25 lines
912 B
Go
package response
|
|
|
|
// StatusCode maps the status codes (and description)
|
|
type StatusCode uint16
|
|
|
|
var SWITCHING_PROTOCOLS StatusCode = 101 // handshake success
|
|
var BAD_REQUEST StatusCode = 400 // missing/malformed headers
|
|
var FORBIDDEN StatusCode = 403 // invalid origin policy, TLS required
|
|
var UPGRADE_REQUIRED StatusCode = 426 // invalid WS version
|
|
var NOT_FOUND StatusCode = 404 // unserved or invalid URI
|
|
var INTERNAL StatusCode = 500 // custom error
|
|
|
|
func (sc StatusCode) Explicit() string {
|
|
|
|
switch sc {
|
|
case SWITCHING_PROTOCOLS: return "Switching Protocols"
|
|
case BAD_REQUEST: return "Bad Request"
|
|
case FORBIDDEN: return "Forbidden"
|
|
case UPGRADE_REQUIRED: return "Upgrade Required"
|
|
case NOT_FOUND: return "Not Found"
|
|
case INTERNAL: return "Internal Server Error"
|
|
default:
|
|
return "Unknown Status Code"
|
|
}
|
|
} |