ws/internal/http/upgrade/status_code.go

40 lines
1.0 KiB
Go

package upgrade
// StatusCode maps HTTP status codes (and description)
type StatusCode int
const (
// StatusSwitchingProtocols - handshake success
StatusSwitchingProtocols StatusCode = 101
// StatusBadRequest - missing/malformed headers
StatusBadRequest StatusCode = 400
// StatusForbidden - invalid origin policy, TLS required
StatusForbidden StatusCode = 403
// StatusUpgradeRequired - invalid WS version
StatusUpgradeRequired StatusCode = 426
// StatusNotFound - unserved or invalid URI
StatusNotFound StatusCode = 404
// StatusInternal - custom error
StatusInternal StatusCode = 500
)
// String implements the Stringer interface
func (sc StatusCode) String() string {
switch sc {
case StatusSwitchingProtocols:
return "Switching Protocols"
case StatusBadRequest:
return "Bad Request"
case StatusForbidden:
return "Forbidden"
case StatusUpgradeRequired:
return "Upgrade Required"
case StatusNotFound:
return "Not Found"
case StatusInternal:
return "Internal Server Error"
default:
return "Unknown Status Code"
}
}