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.
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.