fix dir/lookup and col/delete api

1, Fix Layouts first letter capitalized
2, Return http 204 when delete a collection

Signed-off-by: Lei Liu <lei01.liu@horizon.ai>
This commit is contained in:
Lei Liu 2019-10-31 14:25:05 +08:00
parent 8479452934
commit 1bcef02a6c
2 changed files with 8 additions and 4 deletions

View file

@ -18,9 +18,10 @@ import (
) )
func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.Request) { func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.Request) {
collection, ok := ms.Topo.FindCollection(r.FormValue("collection")) collectionName := r.FormValue("collection")
collection, ok := ms.Topo.FindCollection(collectionName)
if !ok { if !ok {
writeJsonError(w, r, http.StatusBadRequest, fmt.Errorf("collection %s does not exist", r.FormValue("collection"))) writeJsonError(w, r, http.StatusBadRequest, fmt.Errorf("collection %s does not exist", collectionName))
return return
} }
for _, server := range collection.ListVolumeServers() { for _, server := range collection.ListVolumeServers() {
@ -35,7 +36,10 @@ func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.R
return return
} }
} }
ms.Topo.DeleteCollection(r.FormValue("collection")) ms.Topo.DeleteCollection(collectionName)
w.WriteHeader(http.StatusNoContent)
return
} }
func (ms *MasterServer) dirStatusHandler(w http.ResponseWriter, r *http.Request) { func (ms *MasterServer) dirStatusHandler(w http.ResponseWriter, r *http.Request) {

View file

@ -23,7 +23,7 @@ func (t *Topology) ToMap() interface{} {
} }
} }
} }
m["layouts"] = layouts m["Layouts"] = layouts
return m return m
} }