func (h *Handler) Interprete(w http.ResponseWriter, r *http.Request) { prog := new(program) if err := json.NewDecoder(r.Body).Decode(prog); err != nil { log4go.Error("Cannot decode json code: %s", err.Error()) } if err := json.NewEncoder(w).Encode(h.LanguageClient.Interprete(prog.Code)); err != nil { log4go.Error("Cannot encode result of code: %s", err.Error()) } }
func (j *JsonHandler) InferJsonStructure(w http.ResponseWriter, r *http.Request) { b, err := ioutil.ReadAll(r.Body) if err != nil { log4go.Error(err) } jsonSchema := j.Parse(b) if err := json.NewEncoder(w).Encode(jsonSchema); err != nil { log4go.Error(err) } }
func (h *Handler) Add(w http.ResponseWriter, r *http.Request) { var rules RuleRepository if err := json.NewDecoder(r.Body).Decode(&rules); err != nil { log4go.Error("Could not decode rule: %s", err.Error()) } h.AddRules(rules) }
func (y *YamlHandler) ParseSchema(schema []byte) []inference.Field { var in []inference.Field if err := yaml.Unmarshal(schema, &in); err != nil { log4go.Error(err) } return in }
func (p *PipelineHandler) ReadPipelineConfig(w http.ResponseWriter, r *http.Request) { if err := json.NewEncoder(w).Encode(p.pipeline); err != nil { message := fmt.Sprintf("Could not read Pipeline: %s", err.Error()) log4go.Error(message) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(message)) } }
func (j *JsonHandler) Parse(msg []byte) []inference.Field { var obj interface{} if err := json.Unmarshal(msg, &obj); err != nil { log4go.Error(err) } data, _ := parse(obj) return data }
func (p *PipelineHandler) NewPipeline(w http.ResponseWriter, r *http.Request) { process := new(process.Process) in := CreateInput() if err := json.NewDecoder(r.Body).Decode(process); err != nil { message := fmt.Sprintf("Could not create Pipeline: %s", err.Error()) log4go.Error(message) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(message)) } p.pipeline = NewPipeline("Default", process, in) }