-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Some sites rely heavily on query parameters. It would be cool if we could specify them in ob-http as easily as we can specify headers.
There is a similar open issue for restclient-mode: pashky/restclient.el#199
Curl already could do the encoding for us (as described in this article).
I belive adapting the parsing in ob-http would not be too hard (I am not great with elisp, but I think I could do that).
So I would like to know what syntax would be best to specify the parameters.
What does the community think?
Possible ideas
This is what I came up with in a short brainstorming.
I am sure there are better ideas out there, I am very open to suggestions.
Lets assume we try to do the following request:
#+begin_src http :pretty :wrap src json
GET https://api.duckduckgo.com/?q=simpsons+characters&format=json&pretty=true
#+end_src
like httpie
httpie uses == (instead of = to distinguish it from header paramers)
https://httpie.io/docs/cli/querystring-parameters
#+begin_src http :pretty :wrap src json
GET https://api.duckduckgo.com/
q==simpsons characters
format==json
pretty==true
#+end_src
like request.el
request.el uses the :param or :data parameter. In our case this would go in the header, but I am not sure how well this would look for ob-http and if we would have won anything by it. I think this is not worth it.
https://github.com/tkf/emacs-request
#+begin_src http :pretty :wrap src json :data q simpsons characters :data format json :data pretty true
GET https://api.duckduckgo.com/
#+end_src
have a keyword
or more of them.
This is currently my favorite.
Similar like the http verb we could have a keyword that marks query parameters. I am not so good with wording, I could imagine:
- PARAM
- DATA
- QUERYPARAM (a bit long perhaps)
#+begin_src http :pretty :wrap src json
GET https://api.duckduckgo.com/
PARAM q=simpsons characters
PARAM format-json
DATA pretty=true
#+end_src