meteor-rest icon indicating copy to clipboard operation
meteor-rest copied to clipboard

Ability to override method and publication prefixes

Open carlevans719 opened this issue 8 years ago • 6 comments

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 :)

carlevans719 avatar May 21 '16 02:05 carlevans719

There's a per-method URL option you can pass already - or do you just want to set a different prefix?

stubailo avatar May 21 '16 03:05 stubailo

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:

  1. 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)
  2. 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.

carlevans719 avatar May 21 '16 12:05 carlevans719

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!

stubailo avatar May 21 '16 17:05 stubailo

I'm not sure if I understand - I was thinking something like this. Is that what you had in mind?

carlevans719 avatar May 22 '16 00:05 carlevans719

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.

zeroasterisk avatar Jun 12 '16 20:06 zeroasterisk

now in PR #109 ^ thanks @carlevans719 & super-thanks @stubailo

zeroasterisk avatar Jun 12 '16 22:06 zeroasterisk