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

is it possible to make an api path prefix optional? #2138

Closed
tansaku opened this issue Dec 1, 2020 · 3 comments
Closed

is it possible to make an api path prefix optional? #2138

tansaku opened this issue Dec 1, 2020 · 3 comments

Comments

@tansaku
Copy link

tansaku commented Dec 1, 2020

in the process of splitting up an API into public and private components, we want to add a public prefix to the API path, but we'd like it to be optional while we are in the process of changing over. Is that possible with the grape prefix keyword? e.g.

prefix :public, optional: true
@dblock
Copy link
Member

dblock commented Dec 1, 2020

I don't think you can make a prefix optional, but have you tried mounting the same API into two locations?

namespace :public do
  mount MyAPI
end
mount MyAPI

@tansaku
Copy link
Author

tansaku commented Dec 1, 2020

That sounds like a great idea - it certainly leaves the original paths intact. However I'm not seeing the same endpoints available with a public/ prefix ... maybe something else in our app ...

I've managed to get it working with:

mount MyAPI => '/public/myapi'
mount MyAPI => '/myapi'

not sure why the namespace didn't seem to work for us - maybe because we're using these named paths ...?

@dblock
Copy link
Member

dblock commented Dec 2, 2020

I'll close this since that's definitely a solution, but if you have time maybe write a spec and reopen if my suggestion doesn't work, that would be a bug.

@dblock dblock closed this as completed Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants