3 ms·
I've had good results embedding a query language into the "query" component of URLs for RESTful GET requests. So something like: https://example.com/messages
by cwp 6y ago
I've had good results embedding a query language into the "query" component of URLs for RESTful GET requests. So something like:
https://example.com/messages?posted-2020-01-01/content~Bob
would compile to SQL like
select *
from messages
where posted < '2020-01-01' or content like '%Bob%'
It's a little bit constrained by the the characters that can appear unescaped in the query component of a URL, which is why it uses '-' instead of '<' for less-than and '/' for 'or'. But there are enough characters to allow a range of operators, and parenthesis is allowed for grouping. Also it's a super set of the usual way that browsers encode forms, so that '=' and '&' work the way you'd expect.
It works pretty well!