dounou9751 2017-06-29 07:28
浏览 76
已采纳

当通配符参数中出现双斜杠时,为什么大猩猩复用器会重定向?

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 ?

  • 写回答

2条回答 默认 最新

  • dongyiba8082 2017-06-29 08:57
    关注

    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/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?