in server/table_handler.go [195:239]
func parseTableForm(w http.ResponseWriter, r *http.Request) *tableCmdReq {
var err error
t := tableCmdReq{}
ct, _, _ := mime.ParseMediaType(r.Header.Get("Content-Type"))
switch {
case ct == "application/x-www-form-urlencoded", ct == "multipart/form-data", ct == "":
t.Cmd = r.FormValue("cmd")
t.Cluster = r.FormValue("cluster")
t.Service = r.FormValue("service")
t.DB = r.FormValue("db")
t.Table = r.FormValue("table")
t.Input = strings.ToLower(r.FormValue("input"))
t.Output = strings.ToLower(r.FormValue("output"))
t.OutputFormat = strings.ToLower(r.FormValue("outputFormat"))
t.Filter = r.FormValue("filter")
t.Type = r.FormValue("type")
t.PublishSchema = strings.ToLower(r.FormValue("publishSchema"))
s := strings.ToLower(r.FormValue("createTopic"))
t.CreateTopic = s == "true" || s == "1"
if r.FormValue("version") != "" {
i, err := strconv.ParseInt(r.FormValue("version"), 10, 32)
if log.E(err) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return nil
}
t.Version = int(i)
}
if t.Offset, t.Limit, err = parsePagination(r); log.E(err) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return nil
}
t.Params = r.FormValue("params")
case ct == "application/json":
if err := json.NewDecoder(r.Body).Decode(&t); log.E(err) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return nil
}
default:
code := http.StatusUnsupportedMediaType
http.Error(w, http.StatusText(code), code)
return nil
}
return &t
}