Skip to content

Commit 6150574

Browse files
committed
added CORS support
1 parent e6c19e8 commit 6150574

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ WORKDIR /go/src
55

66
RUN go get github.com/bhoriuchi/go-bunyan/bunyan
77
RUN go get github.com/gorilla/mux
8+
RUN go get github.com/gorilla/handlers
89

910
RUN mkdir -p /go/src/github.com/cjimti/iotwifi
1011
COPY . /go/src/github.com/cjimti/iotwifi

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
IMAGE ?= iotwifi
1+
IMAGE ?= cjimti/iotwifi:armhf-1.0.1
22
NAME ?= iotwifi
33

4+
all: build push
5+
46
dev: dev_build dev_run
57

8+
build:
9+
docker build -t $(IMAGE) .
10+
11+
push:
12+
docker push $(IMAGE)
13+
614
dev_build:
715
docker build -t $(IMAGE) ./dev/
816

dev/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ WORKDIR /go/src
1313

1414
RUN go get github.com/bhoriuchi/go-bunyan/bunyan
1515
RUN go get github.com/gorilla/mux
16+
RUN go get github.com/gorilla/handlers

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/bhoriuchi/go-bunyan/bunyan"
1313
"github.com/cjimti/iotwifi/iotwifi"
1414
"github.com/gorilla/mux"
15+
"github.com/gorilla/handlers"
1516
)
1617

1718
type ApiReturn struct {
@@ -201,6 +202,7 @@ func main() {
201202
r := mux.NewRouter()
202203
r.Use(allowHeaders)
203204
r.Use(logHandler)
205+
204206

205207
// set app routes
206208
r.HandleFunc("/status", statusHandler)
@@ -211,7 +213,7 @@ func main() {
211213

212214
// serve http
213215
blog.Info("HTTP Listening on " + port)
214-
http.ListenAndServe(":" + port, nil)
216+
http.ListenAndServe(":" + port, handlers.CORS()(r))
215217

216218
}
217219

0 commit comments

Comments
 (0)