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

Add support for query string parameters in route templates #838

Closed
kgriffs opened this issue Jun 30, 2016 · 2 comments
Closed

Add support for query string parameters in route templates #838

kgriffs opened this issue Jun 30, 2016 · 2 comments

Comments

@kgriffs
Copy link
Member

kgriffs commented Jun 30, 2016

We can borrow from RFC 6570 syntax and do something like this:

'/things{?count,detailed}'

Note that all params would default to None if present. I'm assuming we would just pass these as kwargs to the responder method.

Filters could be specified by extending RFC 6570, i.e:

'/things{?count:int,detailed:bool}'
@kgriffs kgriffs added this to the Version 1.3 milestone Jun 30, 2016
@kgriffs kgriffs modified the milestones: Milestone Staging, Triaged (Non-Breaking Changes) Apr 25, 2017
@softgripper
Copy link

softgripper commented May 17, 2017

This is EXACTLY what I'm after.

I'm basically making my own server that wraps an external API, but does some processing on some of the functions, and is accessed by ajax so need to avoid CORS and my own caching.

I've added a route decorator and basically do this.

@route('/market/{instrument}/{currency}/trades?since={timestamp}')
class Trades(RoutedHandler):
     def __init__(self):
         super().__init__()

Of course the 'timestamp' param in the above example does not get passed as **kwargs, but for all simple "/" param based API calls, it's saved me a LOT of time and effort, and is quite elegant.

Then in the super I do

    def on_get(self, req, resp, **kwargs):
        url = config.domain + self.get_route(**kwargs)
        if req.params:
            url += "?{}".format(req.query_string)

        result = requests.get(url)
        resp.body = result.text

I wish I knew how to work around this, but I've only been using Falcon since yesterday. 👍 and it would be nice if the querystring arguments could be used for routing.

@vytas7
Copy link
Member

vytas7 commented Mar 25, 2024

Given this has generated only a limited interest from the community, I think we want to keep the default router focused solely on routing based on req.path. However, I filed a separate issue to be able to easier extend the default router with additions like this one: #2219.

@vytas7 vytas7 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
@vytas7 vytas7 added wontfix and removed needs-decision needs contributor Comment on this issue if you'd like to volunteer to work on this. Thanks! labels Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants