A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Mojo::UserAgent request format

The get(), post(), etc. methods are both too magic, and not magic enough.

They do what I mean, but only if I remember the order or parameters. Luckily Perl has an easy solution to this problem: Named parameters! AKA Passing a hash, like a normal person.


# Existing Mojo::UserAgent interface:
->get('www.☃.net?hello=there' => {Accept => '*/*'});
->post('https://example.com' => json => {top => 'secret'});
# Alternative improved interface (proposed):
->get({
url => 'www.☃.net?hello=there',
headers => { Accept => '*/*' },
});
->post({
url => 'https://example.com',
json => { top => 'secret' },
});