An open API service indexing awesome lists of open source software.

https://github.com/gogaruda/pkg


https://github.com/gogaruda/pkg

Last synced: 6 months ago
JSON representation

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()))
}
```