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

32 lines
874 B
Go
Raw Normal View History

package response
// StatusCode maps the status codes (and description)
type StatusCode uint16
var SWITCHING_PROTOCOLS StatusCode = 101 // handshake success
2018-09-29 12:39:12 +00:00
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
func (sc StatusCode) Message() string {
switch sc {
2018-09-29 12:39:12 +00:00
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"
}
2018-09-29 12:39:12 +00:00
}