Skip to content

Commit

Permalink
Added docstring; more verbose function name
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Meadows committed Jun 15, 2020
1 parent a3ab865 commit 4140a11
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion executor/api/rest/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func (h *CloudeventHeaderMiddleware) Middleware(next http.Handler) http.Handler
})
}

func corsHeaders(next http.Handler) http.Handler {
// handleCORSRequests adds CORS-required headers, and during CORS Preflight
// requests, it will exit the request and the request status will be
// http.StatusOK
func handleCORSRequests(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set(corsAllowOriginHeader, corsAllowOriginValue)
w.Header().Set(corsAllowMethodsHeader, corsAllowMethodsValue)
Expand Down
4 changes: 2 additions & 2 deletions executor/api/rest/middlewares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
. "github.com/onsi/gomega"
)

func TestCORSHeadersGet(t *testing.T) {
func TestCORSHeadersGetRequest(t *testing.T) {
g := NewGomegaWithT(t)

m := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
Expand All @@ -31,7 +31,7 @@ func TestCORSHeadersGet(t *testing.T) {
g.Expect(headerValAllowMethods).To(Equal(corsAllowMethodsValue))
}

func TestCORSHeadersOptions(t *testing.T) {
func TestCORSHeadersOptionsRequest(t *testing.T) {
g := NewGomegaWithT(t)

m := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
Expand Down
2 changes: 1 addition & 1 deletion executor/api/rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (r *SeldonRestApi) Initialise() {
r.Router.Use(puidHeader)
r.Router.Use(cloudeventHeaderMiddleware.Middleware)
r.Router.Use(xssMiddleware)
r.Router.Use(corsHeaders)
r.Router.Use(handleCORSRequests)

switch r.Protocol {
case api.ProtocolSeldon:
Expand Down

0 comments on commit 4140a11

Please sign in to comment.