some api changes
This commit is contained in:
parent
f305f96195
commit
70fd3f71e5
11 changed files with 118 additions and 76 deletions
|
|
@ -86,7 +86,7 @@ func (c *Context) log() {
|
|||
c.Log.Info("access",
|
||||
"addr", c.Request.RemoteAddr,
|
||||
"method", c.Request.Method,
|
||||
"url", c.Request.URL.Path,
|
||||
"path", c.Request.URL.Path,
|
||||
"status", c.Status,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ type Err struct {
|
|||
|
||||
// Error returns the error string
|
||||
func (a Err) Error() string {
|
||||
return `{"message":"` + a.err + `","status":` + strconv.Itoa(a.status) + `}`
|
||||
return `{"error":"` + a.err + `","status":` + strconv.Itoa(a.status) + `}`
|
||||
}
|
||||
|
||||
// Status returns the HTTP status code
|
||||
|
|
@ -35,13 +35,17 @@ func newError(err string, status int) Error {
|
|||
}
|
||||
|
||||
var (
|
||||
ErrBadreq = newError("bad request", http.StatusBadRequest)
|
||||
ErrInvalid = newError("invalid data", http.StatusBadRequest)
|
||||
ErrUnauthorized = newError("unauthorized", http.StatusUnauthorized)
|
||||
ErrForbidden = newError("forbidden", http.StatusForbidden)
|
||||
ErrNotFound = newError("not found", http.StatusNotFound)
|
||||
ErrMNA = newError("method not allowed", http.StatusMethodNotAllowed)
|
||||
ErrExists = newError("resource already exists", http.StatusConflict)
|
||||
ErrISE = newError("internal server error", http.StatusInternalServerError)
|
||||
ErrFollower = newError("follower write forbidden", http.StatusForbidden)
|
||||
ErrInvalidAPIRoute = newError("invalid api route", http.StatusNotFound)
|
||||
ErrBadreq = newError("bad request", http.StatusBadRequest)
|
||||
ErrInvalid = newError("invalid data", http.StatusBadRequest)
|
||||
ErrUnauthorized = newError("unauthorized", http.StatusUnauthorized)
|
||||
ErrForbidden = newError("forbidden", http.StatusForbidden)
|
||||
ErrNotFound = newError("not found", http.StatusNotFound)
|
||||
ErrLBNotFound = newError("loadbalancer not found", http.StatusNotFound)
|
||||
ErrMNA = newError("method not allowed", http.StatusMethodNotAllowed)
|
||||
ErrExists = newError("resource already exists", http.StatusConflict)
|
||||
ErrISE = newError("internal server error", http.StatusInternalServerError)
|
||||
ErrFollower = newError("follower write forbidden", http.StatusForbidden)
|
||||
ErrClusterNotFound = newError("cluster not found", http.StatusNotFound)
|
||||
ErrLBsNotFound = newError("loadbalancers not found", http.StatusNotFound)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue