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
Add a helper to generate the URL for a resource #1264
Comments
(Please comment below re a design proposal if you are interested in taking this on, thanks!) |
Much of the way that The basic premise within that code is to utilize the I can understand that people do want it, but why do people want it? Is generating a URL based on resource a required competency of an API framework? Flask has Jinjna2 bundled for generating HTML so A reason I could be confused is that, "inter-resource delegation"/"to facilitate one resource calling into another" and |
Places I miss
Without something like |
I agree. Perhaps this issue could be renamed if it is about generating the URLs for resources? Given how much weight Roy Fielding puts on link-driven APIs I'm surprised that a REST-focused framework like Falcon does not have a way to create a URL for a resource. E.g, for some hypothetical API, if I query edit: here is essentially how I'm doing it now: class ProductResource(object):
def on_get(self, req, resp):
urljoin = urllib.parse.urljoin
quote = urllib.parse.quote
data = [{'name': prod.name,
'url': urljoin(req.prefix, 'products/' + quote(prod.id))}
for prod in self.products]
resp.media = data
resp.status = falcon.HTTP_OK I'm not primarily a web-developer so I'm not sure how good that is. And what if |
Since #1228 speaks to delegating a response to another resource/route, I think it makes sense to rename this issue to focus solely on generating the hyperlink. |
As a REST-focused framework, Falcon really should make it easier to generate a URL for a given resource. This will help encourage the use of hypermedia by lowering the barrier to entry.
Prior Art
The text was updated successfully, but these errors were encountered: