gin-contrib / cors

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

unable to run example on the latest gin version, cannot use cors.New(config) as type HandlerFunc #10

Closed ishehata closed 8 years ago

ishehata commented 8 years ago

i am trying to use the cors middleware on the latest gin version

./main.go:17: cannot use cors.New(config) (type "gopkg.in/gin-gonic/gin.v1".HandlerFunc) as type "github.com/gin-gonic/gin".HandlerFunc in argument to r.Use

where

r := gin.New()
config := cors.DefaultConfig()
config.AllowOrigins = []string{"http://google.com"}

r.Use(cors.New(config))
r.POST("/api/auth", api.Login)
r.Run()

Operating System: Mac OS X

javierprovecho commented 8 years ago

@eslammostafa please fix your import at the beginning of main.go

use:

import "gopkg.in/gin-gonic/gin.v1"