gin_cors/README.md
2021-12-16 19:46:16 +08:00

31 lines
538 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#gin_cors
##说明
gin框架的cors跨域处理中间件
##使用
go get git@github.com:cowardmrx/gin_cors.git
```go
r := gin.Default()
// 创建cors配置 只要是string类型的一律按照 , 分割只有AccessControlAllowCredentials是字符串类型的bool值
cors := &Cors{
AccessControlAllowOrigins: []string{
"http://localhost",
},
AccessControlAllowMethods: "PUT,POST,GET,DELETE",
}
r.POST("/te", func(c *gin.Context) {
c.JSON(200, gin.H{
"data": "this is data",
})
})
r.Run(":7878")
}
```