Skip to content

Commit

Permalink
#11 - Add Access-Control-Allow-Origin: *
Browse files Browse the repository at this point in the history
  • Loading branch information
caalberts committed Nov 15, 2019
1 parent bc9c5af commit fe5263e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func handlerFunc(schema types.Schema) httprouter.Handle {

log.Infof("request: %s %s", r.Method, r.URL)
log.Infof("response status: %d, body: %s", schema.Status, schema.Response)
w.Header().Add("Access-Control-Allow-Origin", "*")
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(schema.Status)
_, ok := r.URL.Query()["pretty"]
Expand Down
1 change: 1 addition & 0 deletions http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func TestServer_Watch(t *testing.T) {
resp := httptest.NewRecorder()
server.router.ServeHTTP(resp, req)

assert.Equal(t, "*", resp.Header().Get("Access-Control-Allow-Origin"))
assert.Equal(t, "application/json", resp.Header().Get("Content-Type"))
assert.Equal(t, schema.Status, resp.Code)

Expand Down

0 comments on commit fe5263e

Please sign in to comment.