Accept name in body if matches url
parent
51506925bc
commit
afba6a71f0
|
|
@ -131,6 +131,10 @@ func whoPost(namespace string, g storage.Graph, w http.ResponseWriter, r *http.R
|
||||||
if err := json.NewDecoder(r.Body).Decode(&one); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&one); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if one.Name != "" && one.Name != id {
|
||||||
|
http.Error(w, `{"error":"names differ between URL and request body"}`, http.StatusBadRequest)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
one.Name = id
|
one.Name = id
|
||||||
if err := g.Insert(r.Context(), namespace, one); err != nil {
|
if err := g.Insert(r.Context(), namespace, one); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue