mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 16:45:55 +00:00
premature checking
This commit is contained in:
parent
45e4cb40fa
commit
80b321a3ef
1 changed files with 41 additions and 0 deletions
41
core/http.go
41
core/http.go
|
|
@ -42,6 +42,7 @@ func (self *WebService) Run() {
|
|||
mux.HandleFunc("/version", self.HandleVersion)
|
||||
mux.HandleFunc("/ping", self.HandlePing)
|
||||
mux.HandleFunc("/batch", self.HandleBatch)
|
||||
mux.HandleFunc("/set_bit", self.HandleSetBit)
|
||||
s := &http.Server{
|
||||
Addr: ":" + port_string,
|
||||
Handler: mux,
|
||||
|
|
@ -167,6 +168,46 @@ func (self *WebService) HandleQuery(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
}
|
||||
|
||||
type JsonObject map[string]interface{}
|
||||
|
||||
func (self *WebService) HandleSetBit(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "POST" {
|
||||
http.Error(w, "Only POST allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
args_string := r.Form.Get("args")
|
||||
|
||||
var args []JsonObject
|
||||
|
||||
//[{ "db": "3", "frame":"brand.","profile_id": 122,"filter":0, "bitmap_id":123},]
|
||||
if args_string == "" {
|
||||
http.Error(w, "Provide a args json string ", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal([]byte(args_string), &args)
|
||||
for _, obj := range args {
|
||||
db := obj["db"]
|
||||
frame := obj["frame"]
|
||||
profile_id := obj["profile_id"]
|
||||
bitmap_id := obj["bitmap_id"].(uint64)
|
||||
filter := obj["bitmap_id"].(int)
|
||||
results := self.service.Executor.RunPQL(db, pql)
|
||||
}
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
err = encoder.Encode(results)
|
||||
if err != nil {
|
||||
log.Fatal("Error encoding stats")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (self *WebService) HandleStats(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "GET" {
|
||||
http.Error(w, "Only GET allowed", http.StatusMethodNotAllowed)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue