gin-contrib / cors

Official CORS gin's middleware
https://gin-gonic.github.io/gin/
MIT License
1.79k stars 186 forks source link

Not working with gopkg Gin import #22

Closed oreqizer closed 7 years ago

oreqizer commented 7 years ago
import (
  "gopkg.in/gin-contrib/cors.v1"
  "gopkg.in/gin-gonic/gin.v1"
)

func main() {
    app := gin.Default()
    app.Use(cors.Default())  // NOPE - type mismatch
}

changing the import to github directly makes it ok:

import (
  "gopkg.in/gin-contrib/cors.v1"
  "github.com/gin-gonic/gin"
)

func main() {
    app := gin.Default()
    app.Use(cors.Default())  // OK
}
tboerger commented 7 years ago

The example shows the github import, we are working on dropping gopkg.in

cheddarwhizzy commented 7 years ago

I can confirm this issue. If I use the github import, I can't use c.BindJSON() as I get empty values. I created this PR https://github.com/gin-contrib/cors/pull/25

appleboy commented 7 years ago

gopkg.in is being dropped in gin for next release version.