diff options
Diffstat (limited to 'Godeps/_workspace/src/github.com/rs/cors/examples/negroni/server.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/rs/cors/examples/negroni/server.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/rs/cors/examples/negroni/server.go b/Godeps/_workspace/src/github.com/rs/cors/examples/negroni/server.go new file mode 100644 index 000000000..3cb33bff6 --- /dev/null +++ b/Godeps/_workspace/src/github.com/rs/cors/examples/negroni/server.go @@ -0,0 +1,26 @@ +package main + +import ( + "net/http" + + "github.com/codegangsta/negroni" + "github.com/rs/cors" +) + +func main() { + c := cors.New(cors.Options{ + AllowedOrigins: []string{"http://foo.com"}, + }) + + mux := http.NewServeMux() + + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.Write([]byte("{\"hello\": \"world\"}")) + }) + + n := negroni.Classic() + n.Use(c) + n.UseHandler(mux) + n.Run(":3000") +} |