use v6.d.PREVIEW; use Cro::HTTP::Middleware; use Cro::HTTP::BodySerializerSelector; use Ultramarine::Serialiser::XML; my %types = ( xml => 'text/xml', json => 'application/json', jsonp => 'application/javascript', ); class Ultramarine::Middleware::SetContentType does Cro::HTTP::Middleware::Response { method process(Supply:D $response-stream) { supply whenever $response-stream -> $response { with $response.request { my $format = .query-value('f')[0] // 'xml'; with %types{$format} { $response.append-header('Content-type',$_); } } emit $response; } } }