Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 37 lines (30 sloc) 1.182 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
class Bailador::Request {
    use URI::Escape;

    has $.env is rw;

    method params {
        my %ret;
        return {} unless $!env<psgi.input>;
        for $.env<psgi.input>.decode.split('&') -> $p {
            my $pair = $p.split('=', 2);
            %ret{$pair[0]} = uri_unescape $pair[1];
        }
        return %ret;
    }

    method new_for_request($meth, $path) {
        self.new: env => { REQUEST_METHOD => $meth, REQUEST_URI => $path}
    }

    method port { $.env<SERVER_PORT> }
    method request_uri { $.env<REQUEST_URI> }
    method uri { self.request_uri }
    method path { $.env<PATH_INFO> }

    method method { $.env<REQUEST_METHOD> }
    method is_get { self.method eq 'GET' }
    method is_post { self.method eq 'POST' }
    method is_put { self.method eq 'PUT' }
    method is_delete { self.method eq 'DELETE' }
    method is_head { self.method eq 'HEAD' }
    method is_patch { self.method eq 'PATCH' }

    method content_type { $.env<CONTENT_TYPE> }
    method content_length { $.env<CONTENT_LENGTH> }
    method body { $.env<psgi.input> }
}
Something went wrong with that request. Please try again.