0

I am using go-chi router for my application but I am unable to serve "/something" and "/something/" both with one route, if I set my route as "/something"

r := chi.NewRouter()
r.Get("/something", func(writer http.ResponseWriter, request *http.Request) {
    writer.Write([]byte("just for test"))
})

and then request "/something/" its give me 404 page not found error.Is there any way to serve both case with one route?

Zoyd
  • 3,449
  • 1
  • 18
  • 27
0xTanvir
  • 55
  • 1
  • 6

1 Answers1

3

use middleware StripSlashes, that change path "/something/" to "/something"

lofcek
  • 1,165
  • 2
  • 9
  • 18