/gin-cors

CORS Basic Middleware for Gin Gonic

Primary LanguageGo

gin-cors

CORS Basic Middleware for Gin Gonic

Installation

$ go get github.com/afboteros/gin-cors

Usage

import (
    "github.com/gin-gonic/gin"
    "github.com/afboteros/gin-cors"
)

func main() {
	g := gin.New()
	g.Use(cors.Middleware(cors.Options{}))
}

AngularJS OPTIONS Management

When working with AngularJS ngResource, Options method will return error with some libraries, due to status return on this method

if c.Request.Method == Options {
    c.AbortWithStatus(http.StatusNoContent)
}