Skip to content

Commit

Permalink
Revert "Use RedirectSlashes middleware by default Goa mux (#3366)" (#…
Browse files Browse the repository at this point in the history
…3392)

This reverts commit 4df75cd.
  • Loading branch information
tchssk authored Oct 14, 2023
1 parent 6f3aa71 commit 4413fbb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
4 changes: 0 additions & 4 deletions http/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"regexp"

chi "github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)

type (
Expand Down Expand Up @@ -80,9 +79,6 @@ type (
// NewMuxer returns a Muxer implementation based on a Chi router.
func NewMuxer() ResolverMuxer {
r := chi.NewRouter()
// RedirectSlashes must be mounted at the top level of the router.
// See. https://github.com/go-chi/chi/blob/1129e362d6cce6e3805e3bc8dfbaeb34b5129789/middleware/strip_test.go#L105-L107
r.Use(middleware.RedirectSlashes)
r.NotFound(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
ctx := context.WithValue(req.Context(), AcceptTypeKey, req.Header.Get("Accept"))
enc := ResponseEncoder(ctx, w)
Expand Down
10 changes: 0 additions & 10 deletions http/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,6 @@ func TestResolvePattern(t *testing.T) {
w := httptest.NewRecorder()
mux.ServeHTTP(w, req)
assert.True(t, called)
// Make sure the URL with a trailing slash is redirected.
called = false // Reset.
req, _ = http.NewRequest("GET", c.URL+"/", nil)
w = httptest.NewRecorder()
mux.ServeHTTP(w, req)
assert.Equal(t, http.StatusMovedPermanently, w.Code)
req, _ = http.NewRequest("GET", w.Header().Get("Location"), nil)
w = httptest.NewRecorder()
mux.ServeHTTP(w, req)
assert.True(t, called)
})
}
}

0 comments on commit 4413fbb

Please sign in to comment.