[FEATURE] Add unknown parameters to a GET request
See original GitHub issueIs 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:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Namespaced variable would be safer here I guess. Alternatively you could just use
request.query_params
.Thanks for the help here everyone! 👏 🙇
Thanks for reporting back and closing the issue @lsabi 👍