Skip to content
forked from hariharan-uno/cors

Negroni middleware/handler to enable CORS support.

License

Notifications You must be signed in to change notification settings

jamesgroat/cors

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cors

wercker status

Negroni middleware/handler to enable CORS support.

Usage

package main

import (
	"net/http"

	"github.com/codegangsta/negroni"
	"github.com/hariharan-uno/cors"
)

func main() {
	n := negroni.Classic()

	// CORS for https://*.foo.com origins, allowing:
	// - GET and POST methods
	// - Origin header
	options := cors.Options{
		AllowOrigins: []string{"https://*.foo.com"},
		AllowMethods: []string{"GET", "POST"},
		AllowHeaders: []string{"Origin"},
	}

	n.Use(negroni.HandlerFunc(options.Allow))

	mux := http.NewServeMux()
	// map your routes

	n.UseHandler(mux)

	n.Run(":3000")
}

###Documentation

Godoc

Authors

About

Negroni middleware/handler to enable CORS support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%