本文整理匯總了Golang中github.com/eaciit/knot.Request.ResponseConfig方法的典型用法代碼示例。如果您正苦於以下問題:Golang Request.ResponseConfig方法的具體用法?Golang Request.ResponseConfig怎麽用?Golang Request.ResponseConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eaciit/knot.Request
的用法示例。
在下文中一共展示了Request.ResponseConfig方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Say
func (w *WorldController) Say(r *knot.Request) interface{} {
r.ResponseConfig().OutputType = knot.OutputHtml
s := "<b>Hello World</b> "
name := r.Query("name")
if name != "" {
s = s + " " + name
}
s += "</br>"
return s
}
示例2: Cookie
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
}
示例3: Json
func (w *WorldController) Json(r *knot.Request) interface{} {
r.ResponseConfig().OutputType = knot.OutputJson
return struct{ ID, Title string }{"JsonID 00001", "Json Row 01 - Title"}
}
示例4: Session
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
}