func AddA(hs *routing.HTTPSession) routing.HResult { var key string var val string err := hs.ValidCheckVal(` key,R|S,L:0; val,R|S,L:0; `, &key, &val) if err != nil { hs.W.Write([]byte(` { "code":1, "msg":"error" } `)) return routing.HRES_RETURN } Vars[key] = val hs.W.Write([]byte(` { "code":0, "data":"" } `)) return routing.HRES_RETURN }
func GetB(hs *routing.HTTPSession) routing.HResult { var key string err := hs.ValidCheckVal(` key,R|S,L:0; `, &key) if err != nil { hs.W.Write([]byte(` { "code":1, "msg":"error" } `)) return routing.HRES_RETURN } if v, ok := Vars[key]; ok { hs.W.Write([]byte(fmt.Sprintf(` { "code":0, "data":"%v" } `, v))) } else { hs.W.Write([]byte(` { "code":1, "msg":"key not found" } `)) } return routing.HRES_RETURN }
func DelA(hs *routing.HTTPSession) routing.HResult { var key string err := hs.ValidCheckVal(` key,R|S,L:0; `, &key) if err != nil { hs.W.Write([]byte(` { "code":1, "msg":"error" } `)) return routing.HRES_RETURN } if _, ok := Vars[key]; ok { delete(Vars, key) hs.W.Write([]byte(` { "code":0, "data":"" } `)) } else { hs.W.Write([]byte(` { "code":1, "msg":"key not found" } `)) } return routing.HRES_RETURN }
func AddB(hs *routing.HTTPSession) routing.HResult { var key string var val string err := hs.ValidCheckVal(` key,R|S,L:0; val,R|S,L:0; `, &key, &val) if err != nil { hs.W.Write([]byte(` { "code":1, "msg":"error" } `)) return routing.HRES_RETURN } if _, ok := pkga.Vars[key]; ok { Vars[key] = val hs.W.Write([]byte(` { "code":0, "data":"" } `)) } else { hs.W.Write([]byte(` { "code":1, "msg":"key not found" } `)) } return routing.HRES_RETURN }
func (t *T2) SrvHTTP(hs *routing.HTTPSession) routing.HResult { fmt.Println(hs.CheckVal("a")) fmt.Println(hs.CheckVal("b")) fmt.Println(c) c = c + 1 hs.W.Write([]byte("{\"OK\":1}")) return routing.HRES_RETURN }
func JcrStore(hs *routing.HTTPSession) routing.HResult { var cover string err := hs.ValidRVal(` cover,R|S,L:0 `, &cover) if err != nil { return hs.MsgResE(1, err.Error()) } spath := _conf_.SavePath() log.D("saving coverage report to %s", spath) err = util.FWrite(spath, cover) if err != nil { log.E("saving coverage report to %s error:%s", spath, err.Error()) return hs.MsgResE(1, err.Error()) } else { return hs.MsgRes("SUCCESS") } }
func JcrExit(hs *routing.HTTPSession) routing.HResult { log.D("Jcr receiving exit command...") StopSrv() return hs.MsgRes("SUCCESS") }
func JcrJs(hs *routing.HTTPSession) routing.HResult { hs.SendT(fmt.Sprintf("var jcr_store='http://%s%s/store';%s", hs.R.Host, filepath.Dir(hs.R.RequestURI), _jcr_js_), "text/javascript;charset=utf-8") return routing.HRES_RETURN }
func JcrConf(hs *routing.HTTPSession) routing.HResult { hs.JsonRes(_conf_) return routing.HRES_RETURN }
func (f *Favicon) SrvHTTP(hs *routing.HTTPSession) routing.HResult { fmt.Println(hs, f) hs.SendF("favicon.ico", f.Path, "image/x-icon", false) return routing.HRES_RETURN }