Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions http/doc_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type DocIndexHandler struct {
defaultIndexName string
IndexNameLookup varLookupFunc
DocIDLookup varLookupFunc
IndexDocType map[string]interface{}
}

func NewDocIndexHandler(defaultIndexName string) *DocIndexHandler {
Expand Down Expand Up @@ -68,6 +69,12 @@ func (h *DocIndexHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {

// parse request body as json
var doc interface{}
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)
Expand Down