mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
http response name convention.
This commit is contained in:
parent
3f312c84ad
commit
c4978ba376
@ -30,7 +30,7 @@ func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
id, err := utils.NewUID(32)
|
||||
if err != nil {
|
||||
utils.HttpInternalServer(w, err)
|
||||
utils.HttpInternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ func (h *MembersHandler) membersDelete(w http.ResponseWriter, r *http.Request) {
|
||||
member := GetMember(r)
|
||||
|
||||
if err := h.sessions.Delete(member.ID()); err != nil {
|
||||
utils.HttpInternalServer(w, err)
|
||||
utils.HttpInternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ func (h *RoomHandler) boradcastStart(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if err := h.capture.StartBroadcast(data.URL); err != nil {
|
||||
utils.HttpInternalServer(w, err)
|
||||
utils.HttpInternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ func (h *RoomHandler) screenConfiguration(w http.ResponseWriter, r *http.Request
|
||||
size := h.desktop.GetScreenSize()
|
||||
|
||||
if size == nil {
|
||||
utils.HttpInternalServer(w, "Unable to get screen configuration.")
|
||||
utils.HttpInternalServerError(w, "Unable to get screen configuration.")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ func (api *ApiManagerCtx) Authenticate(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
session, err := api.sessions.Authenticate(r)
|
||||
if err != nil {
|
||||
utils.HttpNotAuthenticated(w, err)
|
||||
utils.HttpUnauthorized(w, err)
|
||||
} else {
|
||||
next.ServeHTTP(w, auth.SetSession(r, session))
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ func AdminsOnly(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
session := GetSession(r)
|
||||
if !session.Admin() {
|
||||
utils.HttpNotAuthorized(w)
|
||||
utils.HttpForbidden(w)
|
||||
} else {
|
||||
next.ServeHTTP(w, r)
|
||||
}
|
||||
@ -38,7 +38,7 @@ func HostsOnly(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
session := GetSession(r)
|
||||
if !session.IsHost() {
|
||||
utils.HttpNotAuthorized(w, "Only host can do this.")
|
||||
utils.HttpForbidden(w, "Only host can do this.")
|
||||
} else {
|
||||
next.ServeHTTP(w, r)
|
||||
}
|
||||
@ -49,7 +49,7 @@ func HostsOrAdminsOnly(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
session := GetSession(r)
|
||||
if !session.IsHost() && !session.Admin() {
|
||||
utils.HttpNotAuthorized(w, "Only host can do this.")
|
||||
utils.HttpForbidden(w, "Only host can do this.")
|
||||
} else {
|
||||
next.ServeHTTP(w, r)
|
||||
}
|
||||
|
@ -50,11 +50,11 @@ func HttpBadRequest(w http.ResponseWriter, res ...interface{}) {
|
||||
defHttpError(w, http.StatusBadRequest, "Bad Request.", res...)
|
||||
}
|
||||
|
||||
func HttpNotAuthorized(w http.ResponseWriter, res ...interface{}) {
|
||||
func HttpUnauthorized(w http.ResponseWriter, res ...interface{}) {
|
||||
defHttpError(w, http.StatusUnauthorized, "Access token does not have the required scope.", res...)
|
||||
}
|
||||
|
||||
func HttpNotAuthenticated(w http.ResponseWriter, res ...interface{}) {
|
||||
func HttpForbidden(w http.ResponseWriter, res ...interface{}) {
|
||||
defHttpError(w, http.StatusForbidden, "Invalid or missing access token.", res...)
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ func HttpUnprocessableEntity(w http.ResponseWriter, res ...interface{}) {
|
||||
defHttpError(w, http.StatusUnprocessableEntity, "Unprocessable Entity.", res...)
|
||||
}
|
||||
|
||||
func HttpInternalServer(w http.ResponseWriter, res ...interface{}) {
|
||||
func HttpInternalServerError(w http.ResponseWriter, res ...interface{}) {
|
||||
defHttpError(w, http.StatusInternalServerError, "Internal server error.", res...)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user