去DOC mux.StrictSlash状态:
func (r *Router) StrictSlash(value bool) *Router
StrictSlash defines the trailing slash behavior for new routes. The initial
value is false.
When true, if the route path is "/path/", accessing "/path" will redirect to
the former and vice versa. In other words, your application will always see
the path as specified in the route.
When false, if the route path is "/path", accessing "/path/" will not match
this route and vice versa.
Special case: when a route sets a path prefix using the PathPrefix() method,
strict slash is ignored for that route because the redirect behavior can't
be determined from a prefix alone. However, any subrouters created from that
route inherit the original StrictSlash setting.
因此,为了避免重定向您可以mux.NewRouter().StrictSlash(false)
这相当于mux.NewRouter()
或使用带有斜杠的URL即router.HandleFunc("/suggestions/", handleSuggestions).Methods("GET")
清除浏览器缓存并重试 – Bhavana
我做了离子,我用卷曲命令行:) –
ohh ..对不起..没有注意到.. :( – Bhavana