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