Browse Source

updateTyp auf form-data umgestellt

pull/1/head
Georg Spar 1 year ago
parent
commit
265bcab8c2
  1. 16
      wdm.go

16
wdm.go

@ -183,12 +183,24 @@ func updateTypHandler(writer http.ResponseWriter, req *http.Request) {
if req.Method == http.MethodOptions { if req.Method == http.MethodOptions {
return return
} }
body, err := io.ReadAll(req.Body)
err := req.ParseMultipartForm(64 << 20)
if err != nil { if err != nil {
writer.WriteHeader(http.StatusBadRequest) writer.WriteHeader(http.StatusBadRequest)
return
} }
var typ Typ var typ Typ
json.Unmarshal(body, &typ) if req.Form["bezeichnung"] != nil {
typ.Bezeichnung = req.FormValue("bezeichnung")
} else {
body, err := io.ReadAll(req.Body)
if err != nil {
writer.WriteHeader(http.StatusBadRequest)
}
var typ Typ
json.Unmarshal(body, &typ)
}
log.Println("Name = ", typ.Bezeichnung) log.Println("Name = ", typ.Bezeichnung)
log.Info("updating Typ", typ.Bezeichnung) log.Info("updating Typ", typ.Bezeichnung)
res, err := UpdateTyp(typ) res, err := UpdateTyp(typ)

Loading…
Cancel
Save