aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/rs/cors/examples/alice/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'Godeps/_workspace/src/github.com/rs/cors/examples/alice/server.go')
-rw-r--r--Godeps/_workspace/src/github.com/rs/cors/examples/alice/server.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/rs/cors/examples/alice/server.go b/Godeps/_workspace/src/github.com/rs/cors/examples/alice/server.go
new file mode 100644
index 000000000..0a3e15cb8
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/rs/cors/examples/alice/server.go
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "net/http"
+
+ "github.com/justinas/alice"
+ "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\"}"))
+ })
+
+ chain := alice.New(c.Handler).Then(mux)
+ http.ListenAndServe(":8080", chain)
+}