Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (4 months ago)
- Default Branch: main
- Last Pushed: 2024-12-12T00:09:56.000Z (about 2 months ago)
- Last Synced: 2024-12-20T02:09:15.724Z (about 2 months ago)
- Topics: cors, cors-enabled, cors-headers, cors-middleware, gin, gin-framework, gin-gonic
- Language: Go
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
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)