Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1005 Bytes

README.md

File metadata and controls

48 lines (33 loc) · 1005 Bytes

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