예제 #1
0
파일: hello.go 프로젝트: shanks-hongfa/wine
func logger(c *wine.Context) {
	startAt := time.Now()
	c.Next()
	duration := time.Since(startAt)
	timeStr := fmt.Sprintf("%dus", duration/1000)
	gox.LInfo(c.Request.Method, c.Request.RequestURI, timeStr)
}
예제 #2
0
파일: hello.go 프로젝트: shanks-hongfa/wine
func login(c *wine.Context) {
	account := c.RequestParams.GetStr("account")
	password := c.RequestParams.GetStr("password")
	fmt.Println(account, password)
	resp := map[string]interface{}{"status": "success"}
	c.JSON(resp)
}
예제 #3
0
파일: hello.go 프로젝트: shanks-hongfa/wine
func auth(c *wine.Context) {
	sid := c.Get("session_id")
	fmt.Println(sid)
	//auth sid
	//...
	authorized := false

	if authorized {
		//call the next handler
		c.Next()
	} else {
		//abort the handling process, send an error response
		resp := map[string]interface{}{"msg": "authorization failed"}
		c.JSON(resp)
	}
}
예제 #4
0
파일: hello.go 프로젝트: shanks-hongfa/wine
func updateName(c *wine.Context) {
	name := c.RequestParams.GetStr("name")
	resp := map[string]interface{}{"name": name}
	c.JSON(resp)
}
예제 #5
0
파일: hello.go 프로젝트: shanks-hongfa/wine
func getProfile(c *wine.Context) {
	id := c.RequestParams.GetStr("id")
	resp := map[string]interface{}{"profile": "This is " + id + "'s profile"}
	c.JSON(resp)
}