Browse Source

add http context method

fancl 2 years ago
parent
commit
1c7cf756dc
1 changed files with 8 additions and 0 deletions
  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, ",")