mirror of https://github.com/cbeuw/Cloak
Fix CORS and POST handler
This commit is contained in:
parent
6af97e2c22
commit
e1c879a478
|
|
@ -56,6 +56,9 @@ func (manager *localManager) registerMux() *gmux.Router {
|
|||
r.HandleFunc("/admin/users/{UID}", manager.getUserInfoHlr).Methods("GET")
|
||||
r.HandleFunc("/admin/users/{UID}", manager.writeUserInfoHlr).Methods("POST")
|
||||
r.HandleFunc("/admin/users/{UID}", manager.deleteUserHlr).Methods("DELETE")
|
||||
r.Methods("OPTIONS").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET,POST,DELETE,OPTIONS")
|
||||
})
|
||||
r.Use(corsMiddleware)
|
||||
return r
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func (manager *localManager) writeUserInfoHlr(w http.ResponseWriter, r *http.Req
|
|||
return
|
||||
}
|
||||
|
||||
jsonUinfo := gmux.Vars(r)["UserInfo"]
|
||||
jsonUinfo := r.FormValue("UserInfo")
|
||||
if jsonUinfo == "" {
|
||||
http.Error(w, "UserInfo cannot be empty", http.StatusBadRequest)
|
||||
return
|
||||
|
|
@ -112,7 +112,7 @@ func (manager *localManager) writeUserInfoHlr(w http.ResponseWriter, r *http.Req
|
|||
}
|
||||
|
||||
err = manager.db.Update(func(tx *bolt.Tx) error {
|
||||
bucket, err := tx.CreateBucket(uinfo.UID)
|
||||
bucket, err := tx.CreateBucketIfNotExists(uinfo.UID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue