From c572efe4294d5a0e354e01f2ddaa8b1f0c3cb3dd Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Sat, 2 Dec 2017 12:38:52 -0800 Subject: [PATCH] [docs] Note StrictSlash re-direct behaviour #308 (#321) * [docs] Note StrictSlash re-direct behaviour #308 * StrictSlash enabled routes return a 301 to the client * As per the HTTP standards, non-idempotent methods, such as POST or PUT, will be followed with a GET by the client * Users should use middleware if they wish to change this behaviour to return a HTTP 308. * Update description of StrictSlash --- mux.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mux.go b/mux.go index 9aec0fa..5fd5fa8 100644 --- a/mux.go +++ b/mux.go @@ -164,13 +164,18 @@ func (r *Router) GetRoute(name string) *Route { // 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 +// When true, if the route path is "/path/", accessing "/path" will perform a 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. // +// The re-direct is a HTTP 301 (Moved Permanently). Note that when this is set for +// routes with a non-idempotent method (e.g. POST, PUT), the subsequent re-directed +// request will be made as a GET by most clients. Use middleware or client settings +// to modify this behaviour as needed. +// // 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