浏览代码

add http context method

fancl 2 年之前
父节点
当前提交
1c7cf756dc
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      gateway/http/context.go

+ 8 - 0
gateway/http/context.go

@@ -45,6 +45,14 @@ func (c *Context) Success(val interface{}) (err error) {
 	return c.JSON(&Response{Result: val})
 }
 
+func (c *Context) Redirect(url string, code int) {
+	http.Redirect(c.Response(), c.Request(), url, code)
+}
+
+func (c *Context) SetCookie(cookie *http.Cookie) {
+	http.SetCookie(c.Response(), cookie)
+}
+
 func (c *Context) GetRealIp() string {
 	if ip := c.Request().Header.Get("X-Forwarded-For"); ip != "" {
 		i := strings.IndexAny(ip, ",")