alphapapa / plz.el

An HTTP library for Emacs
GNU General Public License v3.0
200 stars 11 forks source link

URL query parameters? #36

Open mooseyboots opened 1 year ago

mooseyboots commented 1 year ago

hi, i thought i might take a look at this for mastodon.el and/or fedi.el.

i'm a little surprised that plz doesn't have a params arg taking an alist of form data parameters, which is how i'm set up with my http layers.

whats the usual way to send them with plz? i'm not thinking of alists in :body for POST requests, but GET requests that take them in the URL itself, i.e. ?q=xyz.

i can't see any mention of this in the readme, nor examples covering it. probably because it's too obvious.

alphapapa commented 1 year ago

If you mean URL query parameters, plz doesn't handle that itself, it just accepts a URL. You can use the built-in url library to build a URL with query parameters, e.g.

https://github.com/alphapapa/ement.el/blob/60e9a50b8a230c00d92f639ba25040944bcda9ab/ement-api.el#L95-L98

It's a bit awkward to do so, so I'm not necessarily opposed to adding support for this to plz.

mooseyboots commented 1 year ago

ack sorry yes i meant query parameters. i took a quick look at ement.el after posting here to see what you do, and found those lines.

and seeing that, i realized that the point of plz.el isn't to do away w url.el entirely, but maybe more just to avoid its pitfalls.

in fedi.el and lem.el i found they're the most handy thing to have streamlined and simplified. but others' usage needs may differ from mine.

alphapapa commented 1 year ago

Yes, plz is intended to provide an alternative to url-retrieve, not all of url and its libraries.

It would be nice to have a simpler API for URL-building than the one in the linked code, but OTOH, such code is usually written once and then not modified frequently, so I'm not sure a new API would be worth it.