Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[V2] change /api/articles/feed to /api/feed #695

Closed
eandre opened this issue Jul 14, 2021 · 1 comment
Closed

[V2] change /api/articles/feed to /api/feed #695

eandre opened this issue Jul 14, 2021 · 1 comment

Comments

@eandre
Copy link

eandre commented Jul 14, 2021

In the current API spec the routes /api/articles/feed and /api/articles/:slug are ambiguous, in the sense that they use the same path structure. This is a problem for two reasons.

First of all, it makes certain API routes unusable (such as the excellent https://github.com/julienschmidt/httprouter for Go), because the internal trie structure does not lend itself to making this distinction very well.

But perhaps more importantly, it breaks the user experience in a weird way. If you try to view an article with the title Feed, it will have a slug feed and try to look up /api/articles/feed and break, because that returns a list of articles instead of a single article. Overall it becomes an edge case that you have to handle everywhere, in both tools and business logic.

Might I suggest /api/feed instead? It's unambiguous and equally clear!

@geromegrignon geromegrignon changed the title [V2] Avoid ambiguous routes [V2] change /api/articles/feed to /api/feed Aug 24, 2021
@geromegrignon
Copy link
Contributor

Great idea.
Closing it as it's now tracked with #713 for a complete review of existing endpoints.

fanshi1028 added a commit to fanshi1028/realworld that referenced this issue Feb 4, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants