mirror of
https://github.com/warmbly/warmbly.git
synced 2026-08-19 08:01:16 +00:00
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package errx
|
|
|
|
import "net/http"
|
|
|
|
type Code int
|
|
|
|
const (
|
|
BadRequest Code = http.StatusBadRequest
|
|
Unauthorized Code = http.StatusUnauthorized
|
|
Forbidden Code = http.StatusForbidden
|
|
NotFound Code = http.StatusNotFound
|
|
Conflict Code = http.StatusConflict
|
|
Unprocessable Code = http.StatusUnprocessableEntity
|
|
Internal Code = http.StatusInternalServerError
|
|
NotImplemented Code = http.StatusNotImplemented
|
|
ServiceUnavailable Code = http.StatusServiceUnavailable
|
|
)
|
|
|
|
var codeToHTTP = map[Code]int{
|
|
BadRequest: http.StatusBadRequest,
|
|
Unauthorized: http.StatusUnauthorized,
|
|
Forbidden: http.StatusForbidden,
|
|
NotFound: http.StatusNotFound,
|
|
Conflict: http.StatusConflict,
|
|
Unprocessable: http.StatusUnprocessableEntity,
|
|
Internal: http.StatusInternalServerError,
|
|
NotImplemented: http.StatusNotImplemented,
|
|
ServiceUnavailable: http.StatusServiceUnavailable,
|
|
}
|
|
|
|
var codeToString = map[Code]string{
|
|
BadRequest: "Bad Request",
|
|
Unauthorized: "Unauthorized",
|
|
Forbidden: "Forbidden",
|
|
NotFound: "Not Found",
|
|
Conflict: "Conflict",
|
|
Unprocessable: "Unprocessable",
|
|
Internal: "Internal Server Error",
|
|
NotImplemented: "Not Implemented",
|
|
ServiceUnavailable: "Service Unavailable",
|
|
}
|