Search code examples
goslashnamed-parametersgorilla

Why does Gorilla mux redirect when i have double slashes in my wildcard param?


Here my handler :

router.HandleFunc("/g/{gparam:.*}", MyHandler)

Bu when i pass something like "123://abc" as param it redirect and modify the param in url to "123:/abc".

is their a way to avoid that ?


Solution

  • It's intended behavior, and is configurable. By default, Gorilla mux will do path cleaning, i.e. removing double slash etc. for new router. You can left the double slash as is by:

    router.SkipClean(true)
    

    The SkipClean documentation says:

    ...
    When true, if the route path is "/path//to", it will remain with the double slash. This is helpful if you have a route like: /fetch/http://xkcd.com/534/