meteor-rest
meteor-rest copied to clipboard
Ability to override method and publication prefixes
Currently, methods are available at /methods/<method-name>
and publications at /publications/<publication-name>
. I'd like to be able to override these (probably with SimpleRest.configure
) to something different.
Can you think of any issues with this? I'm happy to raise a PR if it helps :)
There's a per-method URL option you can pass already - or do you just want to set a different prefix?
Yeah this would change just the hardcoded 'methods/' and 'publications/' part of the URL (in my case, I'd set both to 'api/').
I'd rather avoid using the per-method URL option if possible for a couple of reasons:
- It means writing a bit more code (either because each individual method needs wrapping in Meteor.method() or because of maintaining a map of method names -> urls)
- I'd just be overriding the 'methods/' part of each one (because I'm already setting the name in the method definition)
As an example, I would be naming a method 'users/profile/avatar', then overriding the URL to 'api/users/profile/avatar'. Likewise with a 'users' publication, I would override to 'api/users'.
What do you think?
There's a per-method URL option you can pass already - or do you just want to set a different prefix?
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/stubailo/meteor-rest/issues/106#issuecomment-220755114
This E-mail is confidential. It may also be legally privileged. If you are not the addressee you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return E-mail. Internet communications cannot be guaranteed to be timely secure, error or virus-free. The sender does not accept liability for any errors or omissions.
I'd say the best thing would be to have a global configurable function that maps the name of the method or publication to a URL. I'd definitely accept a pr that implements that!
I'm not sure if I understand - I was thinking something like this. Is that what you had in mind?
YES! I would very much like to be able to configure these URLs...
@carlevans719 link/commit is a good start, allowing us to specify our own prefixes.
In my mind, though, I'd want to be able to translate any and all routes.
- Perhaps through a configured
translatePath
function? (simplest) - Perhaps by comparing to a configured map of routes.
- Alternatively, I'd be happy with keeping the current, automatic routes, and simply being able to map aliases to them.
now in PR #109 ^ thanks @carlevans719 & super-thanks @stubailo