1
0
mirror of https://github.com/astaxie/beego.git synced 2025-02-02 16:47:12 +00:00
Beego/context/context.go

35 lines
738 B
Go
Raw Normal View History

2013-08-21 17:59:31 +08:00
package context
2013-08-21 13:24:14 +08:00
import (
"net/http"
)
type Context struct {
Input *BeegoInput
Output *BeegoOutput
Request *http.Request
ResponseWriter http.ResponseWriter
}
func (ctx *Context) Redirect(status int, localurl string) {
ctx.Output.Header("Location", localurl)
ctx.Output.SetStatus(status)
}
2013-09-10 00:00:11 +08:00
func (ctx *Context) Abort(status int, body string) {
ctx.Output.SetStatus(status)
ctx.Output.Body([]byte(body))
}
2013-08-21 13:24:14 +08:00
func (ctx *Context) WriteString(content string) {
ctx.Output.Body([]byte(content))
}
func (ctx *Context) GetCookie(key string) string {
return ctx.Input.Cookie(key)
}
func (ctx *Context) SetCookie(name string, value string, others ...interface{}) {
ctx.Output.Cookie(name, value, others...)
}