Skip to content

Commit

Permalink
chore: remove trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
yquansah committed Jun 14, 2023
1 parent 4695293 commit d539e39
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/cmd/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ func NewHTTPServer(
r.Mount("/debug", middleware.Profiler())
r.Mount("/metrics", promhttp.Handler())

// Middleware to trim the trailing slash off of the request URL if it
// exists.
// r.Use(func(h http.Handler) http.Handler {
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// if strings.HasSuffix(r.URL.Path, "/") {
// fmt.Println("GETTING IN HERE...")
// nurl, err := url.Parse(strings.TrimSuffix(r.URL.String(), "/"))
// if err != nil {
// panic(err)
// }

// fmt.Println("NEW URL: ", nurl)
// r.URL = nurl
// }
// h.ServeHTTP(w, r)
// })
// })

r.Group(func(r chi.Router) {
if key := cfg.Authentication.Session.CSRF.Key; key != "" {
logger.Debug("enabling CSRF prevention")
Expand Down

0 comments on commit d539e39

Please sign in to comment.