示例#1
0
文件: server.go 项目: eaciit/sebar
func (s *ServerController) Student(kr *knot.Request) interface{} {
	kr.RouteConfig().OutputType = knot.OutputJson
	return struct {
		ID    string
		Name  string
		Score int
	}{"Student01", "Nama Student", 100}
}
示例#2
0
文件: server.go 项目: eaciit/sebar
func (s *ServerController) Status(kr *knot.Request) interface{} {
	ret := "Sebar Server v 0.9 (c) EACIIT \n"
	keys := kr.QueryKeys()
	for _, k := range keys {
		ret += fmt.Sprintf("%s = %v \n", k, kr.Query(k))
	}
	return ret
}
示例#3
0
文件: hello.go 项目: arfian/knot
func (w *WorldController) Say(r *knot.Request) interface{} {
	r.ResponseConfig().OutputType = knot.OutputHtml
	s := "<b>Hello World</b>&nbsp;"
	name := r.Query("name")
	if name != "" {
		s = s + " " + name
	}
	s += "</br>"
	return s
}
示例#4
0
文件: hello.go 项目: arfian/knot
func (w *WorldController) Cookie(r *knot.Request) interface{} {
	r.ResponseConfig().OutputType = knot.OutputHtml
	cvalue := ""
	cookiename := "mycookie"
	c, _ := r.Cookie(cookiename)
	if c == nil {
		r.SetCookie(cookiename, "Arief Darmawan", 30*24*time.Hour)
	} else {
		cvalue = c.Value
		c.Value = "Arief Darmawan" + time.Now().String()
		c.Expires = time.Now().Add(24 * 30 * time.Hour)
	}
	return "Cookie value is " + cvalue
}
示例#5
0
func StopServer(r *knot.Request) interface{} {
	r.Server().Stop()
	return nil
}
示例#6
0
文件: hello.go 项目: arfian/knot
func (w *WorldController) Json(r *knot.Request) interface{} {
	r.ResponseConfig().OutputType = knot.OutputJson
	return struct{ ID, Title string }{"JsonID 00001", "Json Row 01 - Title"}
}
示例#7
0
文件: hello.go 项目: arfian/knot
func (w *WorldController) Session(r *knot.Request) interface{} {
	r.ResponseConfig().OutputType = knot.OutputHtml
	s := r.Session("NameAndTime", "").(string)
	r.SetSession("NameAndTime", "Arief Darmawan : "+time.Now().String())
	return "Session value is " + s
}
示例#8
0
文件: server.go 项目: eaciit/sebar
func (s *ServerController) Stop(r *knot.Request) interface{} {
	r.Server().Stop()
	return nil
}