https://github.com/onlynico43/gin-cors
CORS Middleware for gin gonic
https://github.com/onlynico43/gin-cors
cors cors-enabled cors-headers cors-middleware gin gin-framework gin-gonic
Last synced: 5 months ago
JSON representation
CORS Middleware for gin gonic
- Host: GitHub
- URL: https://github.com/onlynico43/gin-cors
- Owner: OnlyNico43
- License: gpl-3.0
- Created: 2024-10-22T12:00:04.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-02-04T11:33:36.000Z (5 months ago)
- Last Synced: 2025-02-04T12:28:44.862Z (5 months ago)
- Topics: cors, cors-enabled, cors-headers, cors-middleware, gin, gin-framework, gin-gonic
- Language: Go
- Homepage:
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gin Cors Middleware
The gin-cors package can be used in every [Gin](https://github.com/gin-gonic/gin) project and configure the cors behaviour of your application.
## Getting started
After installing and setting up Go you can create yor first project with gin.In your main go file create a basic gin http server with the gin-cors middleware package
```go
package mainimport (
"net/http""github.com/gin-gonic/gin"
cors "github.com/OnlyNico43/gin-cors"
)func main() {
r := gin.Default()r.Use(cors.CorsMiddleware(cors.DefaultConfig()))
r.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "pong")
})r.Run(":8080")
}
```Done, now your application is equipped with a basic cors configuration
## How to configure
You can either use the default configuration or decide to use your own values in the Config object.For more details please see the [documentation](https://pkg.go.dev/github.com/OnlyNico43/gin-cors)