1
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"go-admin/common/actions"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
"go-admin/common/actions"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -15,6 +18,13 @@ const (
|
||||
|
||||
func InitMiddleware(r *gin.Engine) {
|
||||
r.Use(DemoEvn())
|
||||
r.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{"*"}, // 允许所有
|
||||
AllowMethods: []string{"GET", "POST", "PUT", "DELETE"}, // 允许的方法
|
||||
AllowHeaders: []string{"Origin", "Content-Length", "Content-Type", "Authorization", "Accept-Language"},
|
||||
ExposeHeaders: []string{"Content-Length", "Authorization"},
|
||||
AllowCredentials: true, // 允许携带 cookie
|
||||
}))
|
||||
// 数据库链接
|
||||
r.Use(WithContextDb)
|
||||
// 日志处理
|
||||
|
||||
Reference in New Issue
Block a user