Rename handlers

This commit is contained in:
Qian Wang 2019-07-25 13:09:36 +01:00
parent 09bdae2584
commit 8ff0f3d17e
2 changed files with 6 additions and 6 deletions

View File

@ -53,9 +53,9 @@ func corsMiddleware(next http.Handler) http.Handler {
func (manager *localManager) registerMux() *gmux.Router { func (manager *localManager) registerMux() *gmux.Router {
r := gmux.NewRouter() r := gmux.NewRouter()
r.HandleFunc("/admin/users", manager.listAllUsersHlr).Methods("GET") r.HandleFunc("/admin/users", manager.listAllUsersHlr).Methods("GET")
r.HandleFunc("/admin/users/{UID}", manager.getUserInfo).Methods("GET") r.HandleFunc("/admin/users/{UID}", manager.getUserInfoHlr).Methods("GET")
r.HandleFunc("/admin/users/{UID}", manager.writeUserInfo).Methods("POST") r.HandleFunc("/admin/users/{UID}", manager.writeUserInfoHlr).Methods("POST")
r.HandleFunc("/admin/users/{UID}", manager.deleteUser).Methods("DELETE") r.HandleFunc("/admin/users/{UID}", manager.deleteUserHlr).Methods("DELETE")
r.Use(corsMiddleware) r.Use(corsMiddleware)
return r return r
} }

View File

@ -45,7 +45,7 @@ func (manager *localManager) listAllUsersHlr(w http.ResponseWriter, r *http.Requ
_, _ = w.Write(resp) _, _ = w.Write(resp)
} }
func (manager *localManager) getUserInfo(w http.ResponseWriter, r *http.Request) { func (manager *localManager) getUserInfoHlr(w http.ResponseWriter, r *http.Request) {
b64UID := gmux.Vars(r)["UID"] b64UID := gmux.Vars(r)["UID"]
if b64UID == "" { if b64UID == "" {
http.Error(w, "UID cannot be empty", http.StatusBadRequest) http.Error(w, "UID cannot be empty", http.StatusBadRequest)
@ -84,7 +84,7 @@ func (manager *localManager) getUserInfo(w http.ResponseWriter, r *http.Request)
_, _ = w.Write(resp) _, _ = w.Write(resp)
} }
func (manager *localManager) writeUserInfo(w http.ResponseWriter, r *http.Request) { func (manager *localManager) writeUserInfoHlr(w http.ResponseWriter, r *http.Request) {
b64UID := gmux.Vars(r)["UID"] b64UID := gmux.Vars(r)["UID"]
if b64UID == "" { if b64UID == "" {
http.Error(w, "UID cannot be empty", http.StatusBadRequest) http.Error(w, "UID cannot be empty", http.StatusBadRequest)
@ -143,7 +143,7 @@ func (manager *localManager) writeUserInfo(w http.ResponseWriter, r *http.Reques
w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusCreated)
} }
func (manager *localManager) deleteUser(w http.ResponseWriter, r *http.Request) { func (manager *localManager) deleteUserHlr(w http.ResponseWriter, r *http.Request) {
b64UID := gmux.Vars(r)["UID"] b64UID := gmux.Vars(r)["UID"]
if b64UID == "" { if b64UID == "" {
http.Error(w, "UID cannot be empty", http.StatusBadRequest) http.Error(w, "UID cannot be empty", http.StatusBadRequest)