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

Support for trailing route components after named component #385

Open
seantjohnson-dev opened this issue Aug 9, 2018 · 0 comments
Open
Labels
Milestone

Comments

@seantjohnson-dev
Copy link

Hey there,

I was just trying to create a custom route for my application and I noticed that the method 'registerRoute' only allows a named parameter to live at the end of the endpoint structure. For example, the following route works just fine.

WP.registerRoute('gf/v2', "/entries/(?P<id>\\d+)");

The above route will create a final url resembling something like https://youdomain.com/wp-json/gf/v2/entries/77

However, the following use of registerRoute does not work.

WP.registerRoute('gf/v2', "/entries/(?P<id>\\d+)/notifications");

The route above still produces the same final url structure as the first example I listed above.

I end up getting this https://youdomain.com/wp-json/gf/v2/entries/77 instead of https://youdomain.com/wp-json/gf/v2/entries/77/notifications.

This happens to be the structure of a few of the routes created by the gravity forms rest api plugin.

image

However, this endpoint structure happens to be quite common amongst many other rest api plugins as well.

I don't know how to get the trailing slug of the url to be added to the end of the path. Is this currently supported and I'm just missing something obvious or would this need to be a new feature? Any help would be much appreciated.

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

No branches or pull requests

2 participants