Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
add cors headers. Closes #255 (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthenw authored Aug 10, 2017
1 parent 0a9a039 commit 8bbeaec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/julienschmidt/httprouter"
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/cors"

"github.com/serverless/event-gateway/db"
"github.com/serverless/event-gateway/functions"
Expand Down Expand Up @@ -46,7 +47,7 @@ func StartConfigAPI(config httpapi.Config) {
}
ev := &http.Server{
Addr: ":" + strconv.Itoa(int(config.Port)),
Handler: apiHandler,
Handler: cors.Default().Handler(apiHandler),
ReadTimeout: 3 * time.Second,
WriteTimeout: 3 * time.Second,
}
Expand Down
3 changes: 2 additions & 1 deletion api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strconv"
"time"

"github.com/rs/cors"
"github.com/serverless/event-gateway/metrics"
"github.com/serverless/event-gateway/router"
"github.com/serverless/event-gateway/targetcache"
Expand All @@ -18,7 +19,7 @@ func StartEventsAPI(config httpapi.Config) {
router.StartWorkers()
ev := &http.Server{
Addr: ":" + strconv.Itoa(int(config.Port)),
Handler: router,
Handler: cors.Default().Handler(router),
ReadTimeout: 3 * time.Second,
WriteTimeout: 3 * time.Second,
}
Expand Down
13 changes: 8 additions & 5 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ import:
- gomock
- package: github.com/satori/go.uuid
version: ^v1.1.0
- package: github.com/rs/cors
version: ^1.2.0

0 comments on commit 8bbeaec

Please sign in to comment.