func (q queryHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) { err := request.ParseForm() if err != nil { errorResponse(writer, http.StatusBadRequest, err) return } parsedForm := parseQueryForm(request) log.Infof("INPUT: %+v\n", parsedForm) cmd, err := query.Parse(parsedForm.input) if err != nil { errorResponse(writer, http.StatusBadRequest, err) return } cmd, profiler := query.NewProfilingCommand(cmd) result, err := cmd.Execute(q.context) if err != nil { errorResponse(writer, http.StatusInternalServerError, err) return } response := response{ Body: result, Name: cmd.Name(), } if parsedForm.profile { response.Profile = convertProfile(profiler) } bodyResponse(writer, response) if q.hook.OnQuery != nil { q.hook.OnQuery <- profiler } }
func (q queryHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) { err := request.ParseForm() if err != nil { errorResponse(writer, http.StatusBadRequest, err) return } parsedForm := parseQueryForm(request) log.Infof("INPUT: %+v\n", parsedForm) cmd, err := query.Parse(parsedForm.input) if err != nil { errorResponse(writer, http.StatusBadRequest, err) return } cmd, profiler := query.NewProfilingCommand(cmd) ctx := q.context ctx.UserSpecifiableConfig = api.UserSpecifiableConfig{ IncludeRawData: parsedForm.includeRaw, } result, err := cmd.Execute(ctx) if err != nil { errorResponse(writer, http.StatusInternalServerError, err) return } response := response{ Body: result.Body, Metadata: result.Metadata, Name: cmd.Name(), } if parsedForm.profile { response.Profile = convertProfile(profiler) } bodyResponse(writer, request, response) if q.hook.OnQuery != nil { q.hook.OnQuery <- profiler } }