初始
This commit is contained in:
31
internal/app/common/logic/middleware/middleware.go
Normal file
31
internal/app/common/logic/middleware/middleware.go
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* @desc:中间件处理
|
||||
* @company:云南奇讯科技有限公司
|
||||
* @Author: yixiaohu<yxh669@qq.com>
|
||||
* @Date: 2022/9/28 9:08
|
||||
*/
|
||||
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/common/service"
|
||||
)
|
||||
|
||||
func init() {
|
||||
service.RegisterMiddleware(New())
|
||||
}
|
||||
|
||||
func New() *sMiddleware {
|
||||
return &sMiddleware{}
|
||||
}
|
||||
|
||||
type sMiddleware struct{}
|
||||
|
||||
func (s *sMiddleware) MiddlewareCORS(r *ghttp.Request) {
|
||||
corsOptions := r.Response.DefaultCORSOptions()
|
||||
// you can set options
|
||||
//corsOptions.AllowDomain = []string{"goframe.org", "baidu.com"}
|
||||
r.Response.CORS(corsOptions)
|
||||
r.Middleware.Next()
|
||||
}
|
Reference in New Issue
Block a user