Add explicit status response to OPTIONS handler
Write the http.StatusOK header in the OPTIONS handler and update the unit tests to refer to the response code using the const from the http package.
This commit is contained in:
parent
0a28628c02
commit
ac599d6528
2 changed files with 3 additions and 2 deletions
1
api.go
1
api.go
|
@ -793,6 +793,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
|||
if srv.enableCors {
|
||||
writeCorsHeaders(w, r)
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
return r, nil
|
||||
}
|
||||
|
|
|
@ -1260,7 +1260,7 @@ func TestOptionsRoute(t *testing.T) {
|
|||
}
|
||||
|
||||
router.ServeHTTP(r, req)
|
||||
if r.Code != 200 {
|
||||
if r.Code != http.StatusOK {
|
||||
t.Errorf("Expected response for OPTIONS request to be \"200\", %v found.", r.Code)
|
||||
}
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ func TestGetEnabledCors(t *testing.T) {
|
|||
}
|
||||
|
||||
router.ServeHTTP(r, req)
|
||||
if r.Code != 200 {
|
||||
if r.Code != http.StatusOK {
|
||||
t.Errorf("Expected response for OPTIONS request to be \"200\", %v found.", r.Code)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue