diff options
Diffstat (limited to 'vendor/github.com/rs/cors/examples/nethttp/server.go')
| -rw-r--r-- | vendor/github.com/rs/cors/examples/nethttp/server.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/vendor/github.com/rs/cors/examples/nethttp/server.go b/vendor/github.com/rs/cors/examples/nethttp/server.go new file mode 100644 index 0000000..eaa775e --- /dev/null +++ b/vendor/github.com/rs/cors/examples/nethttp/server.go @@ -0,0 +1,20 @@ +package main + +import ( + "net/http" + + "github.com/rs/cors" +) + +func main() { + c := cors.New(cors.Options{ + AllowedOrigins: []string{"http://foo.com"}, + }) + + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.Write([]byte("{\"hello\": \"world\"}")) + }) + + http.ListenAndServe(":8080", c.Handler(handler)) +} |
