diff options
author | Marius Halden <marius.h@lden.org> | 2015-08-26 13:43:10 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2015-08-26 13:43:10 +0200 |
commit | cc0acdd34052e79f3df368ac1f524de31df19a1b (patch) | |
tree | 505f561b5f16c5b78f07514e8c2b2bdc18fef51d /t/MapIt.pm | |
parent | 1c5c685d0b0904e7ddc6e764e58e8fae08632d1d (diff) | |
parent | 6b84622fb7d58531baa7943abdcc7620999c34ee (diff) |
Merge tag 'v1.6.1' into fiksgatami-dev
Diffstat (limited to 't/MapIt.pm')
-rw-r--r-- | t/MapIt.pm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/t/MapIt.pm b/t/MapIt.pm new file mode 100644 index 000000000..ebef934e1 --- /dev/null +++ b/t/MapIt.pm @@ -0,0 +1,36 @@ +package t::MapIt; + +use JSON; +use Web::Simple; + +use mySociety::Locale; + +has json => ( + is => 'lazy', + default => sub { + JSON->new->pretty->allow_blessed->convert_blessed; + }, +); + +sub dispatch_request { + my $self = shift; + + sub (GET + /postcode/*) { + my ($self, $postcode) = @_; + my $response = $self->postcode($postcode); + # We must make sure we output correctly for testing purposes, we might + # be within a different locale here... + my $json = mySociety::Locale::in_gb_locale { + $self->json->encode($response) }; + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + }, +} + +sub postcode { + my ($self, $postcode) = @_; + return { + wgs84_lat => 51.5, wgs84_lon => 2.1, postcode => $postcode, + }; +} + +__PACKAGE__->run_if_script; |