2021-05-14 15:19:02 +00:00
|
|
|
package upgrade
|
2018-04-25 16:09:26 +00:00
|
|
|
|
|
|
|
// StatusCode maps the status codes (and description)
|
|
|
|
type StatusCode uint16
|
|
|
|
|
2021-05-14 15:19:02 +00:00
|
|
|
const (
|
2021-05-14 14:47:02 +00:00
|
|
|
// SwitchingProtocols - handshake success
|
|
|
|
SwitchingProtocols StatusCode = 101
|
|
|
|
// BadRequest - missing/malformed headers
|
|
|
|
BadRequest StatusCode = 400
|
|
|
|
// Forbidden - invalid origin policy, TLS required
|
|
|
|
Forbidden StatusCode = 403
|
|
|
|
// UpgradeRequired - invalid WS version
|
|
|
|
UpgradeRequired StatusCode = 426
|
|
|
|
// NotFound - unserved or invalid URI
|
|
|
|
NotFound StatusCode = 404
|
|
|
|
// Internal - custom error
|
|
|
|
Internal StatusCode = 500
|
|
|
|
)
|
2018-04-25 16:09:26 +00:00
|
|
|
|
2021-05-14 14:47:02 +00:00
|
|
|
// String implements the Stringer interface
|
|
|
|
func (sc StatusCode) String() string {
|
2018-04-25 16:09:26 +00:00
|
|
|
switch sc {
|
2021-05-14 14:47:02 +00:00
|
|
|
case SwitchingProtocols:
|
2018-09-29 12:39:12 +00:00
|
|
|
return "Switching Protocols"
|
2021-05-14 14:47:02 +00:00
|
|
|
case BadRequest:
|
2018-09-29 12:39:12 +00:00
|
|
|
return "Bad Request"
|
2021-05-14 14:47:02 +00:00
|
|
|
case Forbidden:
|
2018-09-29 12:39:12 +00:00
|
|
|
return "Forbidden"
|
2021-05-14 14:47:02 +00:00
|
|
|
case UpgradeRequired:
|
2018-09-29 12:39:12 +00:00
|
|
|
return "Upgrade Required"
|
2021-05-14 14:47:02 +00:00
|
|
|
case NotFound:
|
2018-09-29 12:39:12 +00:00
|
|
|
return "Not Found"
|
2021-05-14 14:47:02 +00:00
|
|
|
case Internal:
|
2018-09-29 12:39:12 +00:00
|
|
|
return "Internal Server Error"
|
|
|
|
default:
|
|
|
|
return "Unknown Status Code"
|
2018-04-25 16:09:26 +00:00
|
|
|
}
|
2018-09-29 12:39:12 +00:00
|
|
|
}
|