2018-04-25 16:09:26 +00:00
|
|
|
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
|
|
|
|
|
2018-04-26 09:05:08 +00:00
|
|
|
func (sc StatusCode) Message() string {
|
2018-04-25 16:09:26 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|