Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Ability to override method and publication prefixes #106

Open
carlevans719 opened this issue May 21, 2016 · 6 comments
Open

Ability to override method and publication prefixes #106

carlevans719 opened this issue May 21, 2016 · 6 comments

Comments

@carlevans719
Copy link

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

@stubailo
Copy link
Owner

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

@carlevans719
Copy link
Author

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
#106 (comment)

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.

@stubailo
Copy link
Owner

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!

@carlevans719
Copy link
Author

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

@zeroasterisk
Copy link

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 added a commit to zeroasterisk/meteor-rest that referenced this issue Jun 12, 2016
Allowing users to set config function to transform URL paths
stubailo#106
  urlTransform: (type, name) => <urlPath>
@zeroasterisk
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants