From 8c25e1383a23ff1b80838876c7f073c4fe1816a7 Mon Sep 17 00:00:00 2001 From: hktalent <18223385+hktalent@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:48:10 +0800 Subject: [PATCH 1/2] support #1744 2022-10-20 --- http/doc_index.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/http/doc_index.go b/http/doc_index.go index d51a0bc31..f64347a39 100644 --- a/http/doc_index.go +++ b/http/doc_index.go @@ -25,6 +25,7 @@ type DocIndexHandler struct { defaultIndexName string IndexNameLookup varLookupFunc DocIDLookup varLookupFunc + IndexDocType map[string]any } func NewDocIndexHandler(defaultIndexName string) *DocIndexHandler { @@ -67,7 +68,13 @@ func (h *DocIndexHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } // parse request body as json - var doc interface{} + var doc any + if nil != h.IndexDocType { + if v, ok := h.IndexDocType[indexName]; ok { + doc = v + } + } + err = json.Unmarshal(requestBody, &doc) if err != nil { showError(w, req, fmt.Sprintf("error parsing request body as JSON: %v", err), 400) From 98dbf85b7a90927f43ae2affb32a9bc622988e34 Mon Sep 17 00:00:00 2001 From: hktalent <18223385+hktalent@users.noreply.github.com> Date: Thu, 20 Oct 2022 10:07:13 +0800 Subject: [PATCH 2/2] fix 1.18support any 2022-10-20 --- http/doc_index.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http/doc_index.go b/http/doc_index.go index f64347a39..c81be04d5 100644 --- a/http/doc_index.go +++ b/http/doc_index.go @@ -25,7 +25,7 @@ type DocIndexHandler struct { defaultIndexName string IndexNameLookup varLookupFunc DocIDLookup varLookupFunc - IndexDocType map[string]any + IndexDocType map[string]interface{} } func NewDocIndexHandler(defaultIndexName string) *DocIndexHandler { @@ -68,7 +68,7 @@ func (h *DocIndexHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { } // parse request body as json - var doc any + var doc interface{} if nil != h.IndexDocType { if v, ok := h.IndexDocType[indexName]; ok { doc = v