當前位置: 首頁>>代碼示例>>Golang>>正文


Golang routing.HTTPSession類代碼示例

本文整理匯總了Golang中github.com/Centny/gwf/routing.HTTPSession的典型用法代碼示例。如果您正苦於以下問題:Golang HTTPSession類的具體用法?Golang HTTPSession怎麽用?Golang HTTPSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HTTPSession類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: PassengerFindDriver

func PassengerFindDriver(hs *routing.HTTPSession) routing.HResult {
	var uid int64
	var startTime int64
	var sLat float64
	var sLng float64
	var eLat float64
	var eLng float64
	var sCity string
	var eCity string
	t := time.Now()
	err := hs.ValidCheckVal(`
		uid,R|I,R:0;
		startTime,R|I,R:0;
		sLat,R|F,R:0;
		sLng,R|F,R:0;
		eLat,R|F,R:0;
		eLng,R|F,R:0;
		sCity,R|S,L:0;
		eCity,R|S,L:0;
		`, &uid, &startTime, &sLat, &sLng, &eLat, &eLng, &sCity, &eCity)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else if t.Unix()-startTime < 1800 {
		return hs.MsgResE(1, "invalid startTime , need > 30min from now")
	} else {
		s, err := db.FindDriverRoute(uid, startTime, sLat, sLng, eLat, eLng, sCity, eCity)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		} else {
			return hs.MsgRes(s)
		}
	}

}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:34,代碼來源:routeapi.go

示例2: ListBook

func ListBook(hs *routing.HTTPSession) routing.HResult {
	is := []Item{}
	for i := 0; i < 10; i++ {
		it := Item{}
		it.Id = i
		it.Name = fmt.Sprintf("bk-%d", i)
		is = append(is, it)
	}
	return hs.MsgRes(is)
}
開發者ID:Centny,項目名稱:jsupload,代碼行數:10,代碼來源:ctf.go

示例3: Register

func Register(hs *routing.HTTPSession) routing.HResult {
	var userName string
	hobby := ""
	var mobile string
	head := ""
	var gender int64
	gender = 1
	err := hs.ValidCheckVal(`
		userName,R|S,L:0;
		hobby,O|S,L:0;
		mobile,R|S,L:0;
		head,O|S,L:0;
		gender,O|I,R:-1~2;
		`, &userName, &hobby, &mobile, &head, &gender)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.Register(userName, mobile, hobby, head, gender)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		} else {
			return hs.MsgRes(s)
		}
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:25,代碼來源:userapi.go

示例4: hsBuilder

func hsBuilder(method, url_ string, v url.Values, uid int64, uname string) *routing.HTTPSession {
	var hs *routing.HTTPSession = &routing.HTTPSession{}

	hs.S = Session{uid}
	hs.W = writer{new([]byte)}
	req, _ := http.NewRequest(method, url_, strings.NewReader(v.Encode()))
	if method == "POST" {
		req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
	}
	hs.R = req
	hs.Kvs = map[string]interface{}{
		"USR": &usr.Usr{
			Tid: uid,
			Usr: uname,
		},
	}
	return hs
}
開發者ID:tomlovzki,項目名稱:ebs,代碼行數:18,代碼來源:initTest_test.go

示例5: DeleteUserById

func DeleteUserById(hs *routing.HTTPSession) routing.HResult {
	var uid int64
	err := hs.ValidCheckVal(`
		uid,R|I,R:0
		`, &uid)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.DeleteUser(uid)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		}
		return hs.MsgRes(s)
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:15,代碼來源:userapi.go

示例6: DeleteUserByMobile

func DeleteUserByMobile(hs *routing.HTTPSession) routing.HResult {
	var mobile string
	err := hs.ValidCheckVal(`
		mobile,R|S,L:0
		`, &mobile)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.DeleteUserByMobile(mobile)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		}
		return hs.MsgRes(s)
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:15,代碼來源:userapi.go

示例7: Login

func Login(hs *routing.HTTPSession) routing.HResult {
	var mobile string
	err := hs.ValidCheckVal(`
		mobile,R|S,L:0;
		`, &mobile)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.Login(mobile)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		} else {
			return hs.MsgRes(s)
		}
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:16,代碼來源:userapi.go

示例8: SaveAnswer

func SaveAnswer(hs *routing.HTTPSession) routing.HResult {
	var aId int64
	var a string
	err := hs.ValidCheckVal(`
		aId,R|I,R:0;
		a,R|S,L:0;
		`, &aId, &a)
	if err != nil {
		log.E("SaveAnswer arg error:%v", err)
		return hs.MsgResE(1, fmt.Sprintf("%s:%s", common_.ARG_ERROR, err.Error()))
	}
	aParse := []ANSWER2{}
	if err := json.Unmarshal([]byte(a), &aParse); err != nil {
		log.E("%v", err)
		return hs.MsgResE(1, fmt.Sprintf("%s:作答內容格式錯誤,%s", common_.ARG_ERROR, err.Error()))
	}
	sql_ := `update ebs_answer set content=? where tid=?`
	conn := dbMgr.DbConn()
	if _, err := conn.Exec(sql_, a, aId); err != nil {
		log.E("SaveAnswer db error:%v,sql:%s,args:%v", err, sql_, a)
		return hs.MsgResE(2, fmt.Sprintf("%s:%s", common_.DB_ERROR, err.Error()))
	}
	return hs.MsgRes("success")
}
開發者ID:tomlovzki,項目名稱:ebs,代碼行數:24,代碼來源:api.go

示例9: RecF

func RecF(hs *routing.HTTPSession) routing.HResult {
	_, sha, _, err := hs.RecF2("file", "/tmp/")
	if err == nil {
		fmt.Println("receive file:", sha)
		return hs.MsgRes(sha)
	} else {
		fmt.Println("receive file err:", err.Error())
		return hs.MsgResErr2(1, "arg-err", err)
	}
}
開發者ID:Centny,項目名稱:jsupload,代碼行數:10,代碼來源:ctf.go

示例10: ChargeBalance

func ChargeBalance(hs *routing.HTTPSession) routing.HResult {
	var uid int64
	var money float64
	err := hs.ValidCheckVal(`
		uid,R|I,R:0;
		money,R|F,R:0;
		`, &uid, &money)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.ChargeBalance(uid, money)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		} else {
			return hs.MsgRes(s)
		}
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:18,代碼來源:orderapi.go

示例11: GetAnswerRecord

func GetAnswerRecord(hs *routing.HTTPSession) routing.HResult {
	var aId int64
	err := hs.ValidCheckVal(`
		aId,R|I,R:0;
		`, &aId)
	if err != nil {
		log.E("GetAnswerRecord arg error:%v", err)
		return hs.MsgResE(1, fmt.Sprintf("%s:%s", common_.ARG_ERROR, err.Error()))
	}
	conn := dbMgr.DbConn()
	var content sql.NullString
	if err := conn.QueryRow("select content from ebs_answer where tid=?", aId).Scan(&content); err != nil {
		if err != sql.ErrNoRows {
			return hs.MsgResE(2, err.Error())
		}
	}
	return hs.MsgRes(content.String)
}
開發者ID:tomlovzki,項目名稱:ebs,代碼行數:18,代碼來源:api.go

示例12: SrvHTTP

func (v *VideoProc) SrvHTTP(hs *routing.HTTPSession) routing.HResult {
	var tid string
	var duration int64
	err := hs.ValidCheckVal(`
		tid,R|S,L:0;
		duration,R|I,R:0;
		`, &tid, &duration)
	if err != nil {
		return hs.Printf("valid argument error by %v", err)
	}
	var reader = bufio.NewReader(hs.R.Body)
	var frame = util.Map{}
	for {
		bys, err := util.ReadLine(reader, 102400, false)
		if err != nil {
			break
		}
		line := strings.Trim(string(bys), " \n\t")
		lines := strings.SplitN(line, "=", 2)
		lines[0] = strings.Trim(lines[0], " \t")
		if len(lines) < 2 {
			frame[lines[0]] = ""
		} else {
			frame[lines[0]] = lines[1]
		}
		if lines[0] != "progress" {
			continue
		}
		var progress Progress
		frame.ToS(&progress)
		var rate = float64(progress.OutTimeMs) / float64(duration)
		if int(rate*1000)%10 == 0 {
			log.D("NofityProc receive rate(%v%%) to task(%v),duration(%v)", int(rate*100), tid, duration)
		}
		err = v.NotifyProc(tid, rate)
		if err != nil {
			return hs.Printf("notify procgress to task(%v) error by %v", tid, err)
		}
		frame = util.Map{}
	}
	return hs.Printf("%v", "DONE")
}
開發者ID:Centny,項目名稱:ffcm,代碼行數:42,代碼來源:ffcm_c.go

示例13: GetPassengerOrderList

func GetPassengerOrderList(hs *routing.HTTPSession) routing.HResult {
	var uid int64
	var page int64
	var pageCount int64
	err := hs.ValidCheckVal(`
		uid,R|I,R:0;
		page,O|I,R:0;
		pageCount,O|I,R:0;
		`, &uid, &page, &pageCount)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.GetPassengerOrderList(uid, page, pageCount)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		} else {
			return hs.MsgRes(s)
		}
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:20,代碼來源:orderapi.go

示例14: PassengerCancelOrder

func PassengerCancelOrder(hs *routing.HTTPSession) routing.HResult {
	var uid int64
	var oid int64
	var drid int64
	err := hs.ValidCheckVal(`
		uid,R|I,R:0;
		oid,R|I,R:0;
		drid,R|I,R:0;
		`, &uid, &oid, &drid)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.PassengerCancelOrder(uid, oid, drid)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		} else {
			return hs.MsgRes(s)
		}
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:20,代碼來源:orderapi.go

示例15: FillInfo

func FillInfo(hs *routing.HTTPSession) routing.HResult {
	var userName string
	var hobby string
	var head string
	var gender int64
	var uid int64
	err := hs.ValidCheckVal(`
		userName,R|S,L:0;
		hobby,R|S,L:0;
		head,R|S,L:0;
		gender,R|I,R:-1~2;
		uid,R|I,R:0
		`, &userName, &hobby, &head, &gender, &uid)
	if err != nil {
		return hs.MsgResErr(100, "config error", err)
	} else {
		s, err := db.FillInfo(userName, hobby, head, gender, uid)
		if err != nil {
			return hs.MsgResErr2(1, "", err)
		} else {
			return hs.MsgRes(s)
		}
	}
}
開發者ID:caowenhua,項目名稱:gocar,代碼行數:24,代碼來源:userapi.go


注:本文中的github.com/Centny/gwf/routing.HTTPSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。