-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: improve 404 Not Found response message #11818
Conversation
f62deea
to
b4cb568
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I think this should help make it easier to notice the problem.
When we start introducing different versions I think we'll want to update our API docs to include the /v1
prefix in the docs, which should also help.
agent/http.go
Outdated
fmt.Fprint(resp, "Invalid URL path: not a recognized HTTP API endpoint") | ||
} else { | ||
fmt.Fprint(resp, "Invalid URL path: if attempting to use the HTTP API, ensure the path starts with '/v1/'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: maybe a trailing newline on these?
fmt.Fprint(resp, "Invalid URL path: not a recognized HTTP API endpoint") | |
} else { | |
fmt.Fprint(resp, "Invalid URL path: if attempting to use the HTTP API, ensure the path starts with '/v1/'") | |
fmt.Fprintln(resp, "Invalid URL path: not a recognized HTTP API endpoint") | |
} else { | |
fmt.Fprintln(resp, "Invalid URL path: if attempting to use the HTTP API, ensure the path starts with '/v1/'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I'll make this change then merge
@dnephin: I made this mistake relatively often when starting out for that reason... the docs omit the |
When a URL path is not found, return a non-empty message with the 404 status code to help the user understand what went wrong. If the URL path was not prefixed with '/v1/', suggest that may be the cause of the problem (which is a common mistake).
b4cb568
to
2de79ab
Compare
🍒 If backport labels were added before merging, cherry-picking will start automatically. To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/527069. |
🍒✅ Cherry pick of commit f81dd81 onto |
http: improve 404 Not Found response message
When a URL path is not found, return a non-empty message with the 404 status code to help the user understand what went wrong. If the URL path was not prefixed with '/v1/', suggest that may be the cause of the problem (which is a common mistake).
Examples
Path not prefixed with '/v1/`
Path prefixed with '/v1/`