-
Notifications
You must be signed in to change notification settings - Fork 1
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
route-based link providers #22
Comments
It might be easer if the route was named, so I could do this:
Then the Linker would get the product representation and URL to construct its own Link objects to add to the representation, but would not change the representation directly. interface Linker {
onHead(request): Promise<Link[]>;
onGet(request, representation): Promise<Link[]>;
} |
I think this is an interesting idea. The current design definitely doesn't preclude someone writing a middleware that does exactly this, but I am somewhat interested in making this a built-in feature (probably as part of a different middleware, not the router). Are you considering using curveball and would want this feature? |
I don't have an immediate need, but will later this year. The more I think about it, the more I realize this is probably better as a standalone middleware that can plug into curveball, Koa, hapi, etc. One thing that would help, though, would be if curveball's routes were namable so the developer wouldn't have to match on URI pattern but could instead declare the name of the rout they want to link to. |
To support named routes, what I would probably do is create a javascript Then if you want access to a specific controller by name, you can simply find it with |
I'd like a way to register a separate link provider for another resource that is called once the routed request has been fulfilled. This would let me add links to relevant resources without editing that resource.
For instance, if I had a
/products/:id
route and I wanted to add links to an add-to-cart resource, I would like to register a link provider call-back that would get the representation from the product resource and let it provide additional links to go with it. In this example, it would add a link to add that product to a cart.The text was updated successfully, but these errors were encountered: