package logic import ( "HttpServer/conf" "common/logger" "io/ioutil" "strconv" //"log" "net/http" ) //定时处理倒计时 func StartHttpTicker() { } func StartHttpServe() { startServerHttpServe() } //just for test func Testsendhttp() { } func CheckErr(err error) { if err != nil { panic(err) } } func startServerHttpServe() { //------------------------------------------------------------- //http.HandleFunc("/catcafe/ClearData", ClearData) //情况账号的测试接口 //http.HandleFunc("/catcafe/AddWhiteList", AddWhiteList) //情况账号的测试接口 //http.HandleFunc("/catcafe/QueryAllAccount", QueryAllAccount) //查询所有账号的等级信息等数据 //------------------------------------------------------------- http.HandleFunc("/eliminatestar/login", UserLogin) //登录 http.HandleFunc("/eliminatestar/watchads", Watchads) //观看激励视频 http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //获取存钱罐数据 http.HandleFunc("/eliminatestar/getguangold", Getguangold) //获取金币到存钱罐 http.HandleFunc("/eliminatestar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包 err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) CheckErr(err) } func Drawguangold(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) } if Uuid == 0 { SetHeader(w) //logger.Error("Uuid is nil!") return } result, _ := ioutil.ReadAll(r.Body) r.Body.Close() s := string(result) logger.Info("Drawguangold , body:%v,uuid=%v", s, Uuid) HandlerDrawguangold(w, s, Uuid) } func Getguangold(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) } if Uuid == 0 { SetHeader(w) //logger.Error("Uuid is nil!") return } result, _ := ioutil.ReadAll(r.Body) r.Body.Close() s := string(result) logger.Info("Getguangold , body:%v,uuid=%v", s, Uuid) HandlerGetguangold(w, s, Uuid) } func Queryguaninfo(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) } if Uuid == 0 { SetHeader(w) //logger.Error("Uuid is nil!") return } result, _ := ioutil.ReadAll(r.Body) r.Body.Close() s := string(result) logger.Info("Queryguaninfo , body:%v,uuid=%v", s, Uuid) HandlerQueryguaninfo(w, s, Uuid) } func Watchads(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) } if Uuid == 0 { SetHeader(w) //logger.Error("Uuid is nil!") return } result, _ := ioutil.ReadAll(r.Body) r.Body.Close() s := string(result) logger.Info("Watchads , body:%v,uuid=%v", s, Uuid) HandlerWatchads(w, s, Uuid) } func UserLogin(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) } if Uuid == 0 { SetHeader(w) //logger.Error("Uuid is nil!") return } result, _ := ioutil.ReadAll(r.Body) r.Body.Close() s := string(result) logger.Info("UserLogin , body:%v,uuid=%v", s, Uuid) HandlerLogin(w, s, Uuid) }