From b4f943a9305257ba3e3aea5002a24c24e6abe888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=9C=E8=8F=AF?= Date: Sun, 13 Aug 2023 08:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=9E=8Btag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/models.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/routers/models.go b/routers/models.go index ee7f677..949b7c9 100644 --- a/routers/models.go +++ b/routers/models.go @@ -314,8 +314,9 @@ func ModelItemPatch(w http.ResponseWriter, r *http.Request) { return } - // 判断数据类型是否JSON - if r.Header.Get("Content-Type") == "application/json" { + // 判断数据类型是否JSON(正则匹配) + //if r.Header.Get("Content-Type") == "application/json" { + if regexp.MustCompile(`application/json`).MatchString(r.Header.Get("Content-Type")) { // 取出更新数据 var model_new models.Model @@ -369,7 +370,7 @@ func ModelItemPatch(w http.ResponseWriter, r *http.Request) { if model_new.Progress != 0 && model_new.Progress != model.Progress { model.Progress = model_new.Progress } - if model_new.Tags != nil && len(model_new.Tags) != len(model.Tags) { + if model_new.Tags != nil { model.Tags = model_new.Tags }