https://github.com/gogaruda/pkg
https://github.com/gogaruda/pkg
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gogaruda/pkg
- Owner: gogaruda
- Created: 2025-06-21T07:19:25.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-21T07:47:03.000Z (about 1 year ago)
- Last Synced: 2025-06-22T09:18:52.693Z (about 1 year ago)
- Language: Go
- Size: 11.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Personal PKG
## Install
```
go get github.com/gogaruda/pkg@v1.2.3
```
## Middleware
### 1. CORS Middleware
```go
package main
import (
"github.com/gin-gonic/gin"
"github.com/gogaruda/pkg/middleware"
"os"
"strings"
)
func getAllowedOrigins() []string {
origins := os.Getenv("ALLOWED_ORIGINS")
if origins == "" {
return []string{"http://localhost:3000"}
}
return strings.Split(origins, ",")
}
func main() {
r := gin.Default()
r.Use(middleware.CORSMiddleware(getAllowedOrigins()))
}
```