Skip to content
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

Change the url to be ID-based instead of name-based. #116

Open
bmf-san opened this issue May 4, 2024 · 2 comments
Open

Change the url to be ID-based instead of name-based. #116

bmf-san opened this issue May 4, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@bmf-san
Copy link
Owner

bmf-san commented May 4, 2024

I want to change the url to be ID-based instead of name-based.

Names are likely to change, so being indexed is inconvenient because name changes affect them.

@bmf-san bmf-san added the enhancement New feature or request label May 4, 2024
@Salladin95
Copy link

Salladin95 commented May 4, 2024

Hey, can you explain what do you mean by example? Because you have routes that use both :name & :id like these ones:
r.Methods(http.MethodGet).Use(mw.Log, mw.Recovery).Handler(/posts/tags/:name, postController.IndexByTag())
r.Methods(http.MethodGet).Use(mw.Log, mw.Recovery, mw.Auth).Handler(/private/tags/:id, tagController.ShowPrivate())

@bmf-san
Copy link
Owner Author

bmf-san commented May 7, 2024

@Salladin95

Paths with the prefix /private (ex. /private/tags/:id) are assumed to be APIs that can only be used by administrators.
This kind of API is essentially identity-based.

On the other hand, other routes (ex. /posts/tags/:name) are assumed to be public APIs that anyone can use.

I would like to unify all of these routes to be ID-based.

In other words, I want all name-based (paths that include :name) to be ID-based (:id).
ex. /posts/tags/:name → /posts/tags/:id

There are some that include :title in the path, but I'm thinking of including it in the name base as well.

:id, :name, :title, etc. are all named in relation to the columns of the table. Making it ID-based means that you refer to the data by the ID of the table.

I believe that if it is name-based, it is likely to change, so I would like to use an ID that is less likely to change.

P.S.

Names are likely to change, so being indexed is inconvenient because name changes affect them.

Please forget this explanation for now. That was an incorrect sentence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants