ws/internal/http/upgrade/status_code.go

40 lines
949 B
Go
Raw Normal View History

2021-05-14 15:19:02 +00:00
package upgrade
// 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
)
2021-05-14 14:47:02 +00:00
// String implements the Stringer interface
func (sc StatusCode) String() string {
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-09-29 12:39:12 +00:00
}