aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/rs/cors/examples/goji/server.go
blob: 1fb4073aadd5515bdb19b59016dbe42758ace235 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main

import (
    "net/http"

    "github.com/rs/cors"
    "github.com/zenazn/goji"
)

func main() {
    c := cors.New(cors.Options{
        AllowedOrigins: []string{"http://foo.com"},
    })
    goji.Use(c.Handler)

    goji.Get("/", func(w http.ResponseWriter, r *http.Request) {
        w.Header().Set("Content-Type", "application/json")
        w.Write([]byte("{\"hello\": \"world\"}"))
    })

    goji.Serve()
}