in reply to Complex filter queries in a REST API

hi

If you can use Apache as a webserver, I'm a fan of mod_perl and libapreq. The latter enables you to write things like :

my $req = Apache2::Request->new( $r ) ; #récupérer les arguments my (%args, @args) ; #recherche des paramètres de la requête @args = $req->param ; for ( @args ) { $args{ $_ } = Encode::decode_utf8( $req->param($_) ) ; #les double-quotes et les <> viennent interférer avec le html $args{ $_ } =~ tr/<>"/'/ ; #cas de la barre espace, qui décale la colonne suivante; on suppri +me $args{ $_ } =~ s/^\s+$// ; }
which gives you a nice hash with all the parameters sent.
The former (mod_perl) enables you to act at all levels of the apache request cycle, and do pretty much what you want with the request. There is a bit of learning curve, but well worth the investment IMO, especially considering the fact that you know Perl already.

https://marica.fr/
Logiciel de gestion des sinistres assurances, des dossiers contentieux et des contrats pour le service juridique

Replies are listed 'Best First'.
Re^2: Complex filter queries in a REST API
by martell (Hermit) on Mar 26, 2021 at 11:46 UTC

    Thanks for your suggestion, but getting the parameters as such was not my problem. I retrieve them without problems via $c->req->params within Catalyst.

    The question was about having a syntax that i could use for constructing complex conditions for a query in the uri, while avoiding to build myself a complex parser to validate the syntax and translate it to something that i could use in DBIx::Class

    Kind regards