# Pastebin 2m6xdULK class Auth does Cro::HTTP::Middleware::Conditional { method process(Supply $requests) { supply whenever $requests -> $request { my %body = await $request.body; my $user = User.^load(uuid => %body); if $user { emit $request; } else { note "[{ DateTime.now }] Failed authentication from {$request.connection.peer-host} (Auth: {%body})"; emit Cro::HTTP::Response.new(:$request, :403status); } } } } my $application = route { before Auth; get -> 'character', $id { request-body -> %request { my $character = Character.^load($id); note "[{ DateTime.now }] Performing lookup on $id"; if $character { content 'application/json', $character.to-json; } else { not-found; } } } }