mirror of
https://github.com/cowardmrx/gin_cors.git
synced 2025-01-18 18:56:04 +08:00
优化
This commit is contained in:
parent
deb395a24e
commit
19c8199358
10
README.md
10
README.md
@ -4,17 +4,25 @@
|
||||
gin框架的cors跨域处理中间件
|
||||
|
||||
##使用
|
||||
go get git@github.com:cowardmrx/gin_cors.git
|
||||
go get github.com/cowardmrx/gin_cors
|
||||
|
||||
```go
|
||||
r := gin.Default()
|
||||
|
||||
// 创建cors配置 只要是string类型的一律按照 , 分割,只有AccessControlAllowCredentials是字符串类型的bool值
|
||||
cors := &Cors{
|
||||
// 允许的域名
|
||||
AccessControlAllowOrigins: []string{
|
||||
"http://localhost",
|
||||
},
|
||||
// 允许的请求头 使用 ',' 分割
|
||||
AccessControlAllowHeaders: "Authorization",
|
||||
// 允许的请求方式 使用 ',' 分割
|
||||
AccessControlAllowMethods: "PUT,POST,GET,DELETE",
|
||||
// 允许暴露的请求头 使用 ',' 分割
|
||||
AccessControlExposeHeaders: "Authorization",
|
||||
// 允许凭证记录 true | false
|
||||
AccessControlAllowCredentials: 'true'
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user