ws/internal/http/upgrade/response/status_code.go

40 lines
948 B
Go

package response
// StatusCode maps the status codes (and description)
type StatusCode uint16
var (
// 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
)
// String implements the Stringer interface
func (sc StatusCode) String() string {
switch sc {
case SwitchingProtocols:
return "Switching Protocols"
case BadRequest:
return "Bad Request"
case Forbidden:
return "Forbidden"
case UpgradeRequired:
return "Upgrade Required"
case NotFound:
return "Not Found"
case Internal:
return "Internal Server Error"
default:
return "Unknown Status Code"
}
}