question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Add unknown parameters to a GET request

See original GitHub issue

Is your feature request related to a problem

I don’t think it’s a problem. It’s a nice and useful feature that I don’t find mentioned neither on the docs nor by searching.

The solution you would like

The basic idea is to have some parameters of GET requests that are not known in advance. It would be nice to be able to access them, along with predefined parameters (as in this case is limit)

@app.get("/")
async def my_func(limit: int = 0, **kwargs):
    var1 = kwargs["var1"]
    print("Limit is {}".format(limit))
    return {"data": var1}

# Generate a request to the url http://my_domain?var1=hi&var2=hello&limit=10
resp = testclient.get("my_domain", params={"var1": "hi", "var2": "hello", "limit": 10})
assert resp.json()["data"] == "hi"

Describe alternatives you’ve considered

I thought about accessing the raw request, but I can’t find how. Also it’s not a clean way of doing it.

Additional context

Instead of **kwargs, another name may be used, such as params

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
phy25commented, May 7, 2020

Namespaced variable would be safer here I guess. Alternatively you could just use request.query_params.

0reactions
tiangolocommented, Jun 7, 2020

Thanks for the help here everyone! 👏 🙇

Thanks for reporting back and closing the issue @lsabi 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass unknown number of arguments into JavaScript function
length to get the amount of arguments passed to the function. To iterate through the arguments, you would use a loop: for(var i...
Read more >
Documentation - TypeScript 3.0
TypeScript 3.0 adds support to multiple new capabilities to interact with function ... Generic rest parameters and corresponding inference of tuple types.
Read more >
How to write a function that accepts any number of arguments ...
Let's create a function that accepts n number of parameters in ES5: The above screenshot represents the arguments ...
Read more >
Function arguments - Manual
By default, function arguments are passed by value (so that if the value of the argument within the function is changed, it does...
Read more >
HTTP request methods - MDN Web Docs
Chrome Edge CONNECT Full support. ChromeYes. Toggle history Full support. Edge12. Toggle history DELETE Full support. ChromeYes. Toggle history Full support. Edge12. Toggle history GET Full...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found