-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
plugin.location #1767
Comments
What's the use case? |
Generating _link (HAL style hyperlinks) inside a resource generated by a plugin. For example, a customer resource generated by a plugin with a prefix of:
with a route:
should look like this:
I could kludge a way to pull it from the request uri, but it would be more convenient if I could pull the prefix from the plugin itself. |
Wouldn't that logic happen inside a handler? Why can't you just use |
Yes the logic happens inside a handler. I simplified the use case to show only a 'self' link, but I've got multiple routes that can be used for this resource--all of which are entries in the plug-in's route table. My thought was to construct the _links by traversing the route paths. But to provide the complete href for each route, I'd need to know the plug-in route prefix. I could parse the request.path, but that feels like a kludge. I could also pass the prefix as an option to the plugin--probably an easier solution, but also not ideal. If the plugin had a location method (or at least a way to access its prefix) it would make for a cleaner implementation. |
You might consider using my hal library for hapi: |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Any plans for a plugin.location function that combines the server.location() value with the plugin route prefix?
The text was updated successfully, but these errors were encountered: