正在显示
2 个修改的文件
包含
9 行增加
和
9 行删除
| @@ -20,14 +20,14 @@ type BaseController struct { | @@ -20,14 +20,14 @@ type BaseController struct { | ||
| 20 | 20 | ||
| 21 | //Prepare 实现beego.ControllerInterface 的接口 | 21 | //Prepare 实现beego.ControllerInterface 的接口 |
| 22 | func (this *BaseController) Prepare() { | 22 | func (this *BaseController) Prepare() { |
| 23 | - // this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*") | ||
| 24 | - // this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*") | ||
| 25 | - // if this.Ctx.Input.Method() == "OPTIONS" { | ||
| 26 | - // this.Ctx.ResponseWriter.WriteHeader(204) | ||
| 27 | - // this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") | ||
| 28 | - // //this.Ctx.WriteString("") | ||
| 29 | - // return | ||
| 30 | - // } | 23 | + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*") |
| 24 | + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*") | ||
| 25 | + if this.Ctx.Input.Method() == "OPTIONS" { | ||
| 26 | + this.Ctx.ResponseWriter.WriteHeader(204) | ||
| 27 | + this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") | ||
| 28 | + //this.Ctx.WriteString("") | ||
| 29 | + return | ||
| 30 | + } | ||
| 31 | p := this.Ctx.Input.GetData("RouterPattern") | 31 | p := this.Ctx.Input.GetData("RouterPattern") |
| 32 | fmt.Println("====>r:", p) | 32 | fmt.Println("====>r:", p) |
| 33 | } | 33 | } |
-
请 注册 或 登录 后发表评论