Skip to content

Commit c572efe

Browse files
elithrarkisielk
authored andcommitted
[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
1 parent 65ec724 commit c572efe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,18 @@ func (r *Router) GetRoute(name string) *Route {
164164
// StrictSlash defines the trailing slash behavior for new routes. The initial
165165
// value is false.
166166
//
167-
// When true, if the route path is "/path/", accessing "/path" will redirect
167+
// When true, if the route path is "/path/", accessing "/path" will perform a redirect
168168
// to the former and vice versa. In other words, your application will always
169169
// see the path as specified in the route.
170170
//
171171
// When false, if the route path is "/path", accessing "/path/" will not match
172172
// this route and vice versa.
173173
//
174+
// The re-direct is a HTTP 301 (Moved Permanently). Note that when this is set for
175+
// routes with a non-idempotent method (e.g. POST, PUT), the subsequent re-directed
176+
// request will be made as a GET by most clients. Use middleware or client settings
177+
// to modify this behaviour as needed.
178+
//
174179
// Special case: when a route sets a path prefix using the PathPrefix() method,
175180
// strict slash is ignored for that route because the redirect behavior can't
176181
// be determined from a prefix alone. However, any subrouters created from that

0 commit comments

Comments
 (0)