From 265bcab8c29ec57c9d7334f31ca2fa486b164120 Mon Sep 17 00:00:00 2001 From: Georg Spar Date: Sat, 24 Jun 2023 12:44:57 +0200 Subject: [PATCH] updateTyp auf form-data umgestellt --- wdm.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wdm.go b/wdm.go index 4efea18..18fe389 100644 --- a/wdm.go +++ b/wdm.go @@ -183,12 +183,24 @@ func updateTypHandler(writer http.ResponseWriter, req *http.Request) { if req.Method == http.MethodOptions { return } - body, err := io.ReadAll(req.Body) + + err := req.ParseMultipartForm(64 << 20) if err != nil { writer.WriteHeader(http.StatusBadRequest) + return } 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.Info("updating Typ", typ.Bezeichnung) res, err := UpdateTyp(typ)