Open calebhailey opened 4 years ago
I believe we could use https://godoc.org/github.com/gorilla/mux#Router.StrictSlash
Actually I don't think we can rely on the StrictSlash method:
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.
&
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.
I'm no longer sure how to achieve that without adding a bunch of complexity 🤔
It appears this is occurring on the Agent /events
API (/events
works, /events/
returns a 404).
Expected Behavior
API endpoints should work the same with and without trailing slashes.
Current Behavior
Most API endpoints in Sensu Go will 404 if a trailing slash is added to the API route.
Example:
POST /entities
vsPOST /entities/
Example:
POST /events/
vsPOST /events
Example:
GET /entities/
vsGET /entities
Possible Solution
Support routes with and without the trailing slash?
Steps to Reproduce (for bugs)
See examples above.
Context
Let's make this easier for our users!
Your Environment