这是我的处理程序:
router.HandleFunc("/g/{gparam:.*}", MyHandler)
Bu 当我将类似“123://abc”的内容作为参数传递时,它会重定向并将 url 中的参数修改为“123:/abc”。
他们有办法避免这种情况吗?
最佳答案
这是预期的行为,并且是可配置的。默认情况下,Gorilla
mux 将进行路径清理,即为新路由器删除双斜杠等。您可以通过以下方式保留双斜杠:
router.SkipClean(true)
SkipClean文档说:
...
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/
关于go - 当我的通配符参数中有双斜杠时,为什么 Gorilla mux 会重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44818867/