aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/FakeMapit.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2018-06-07 13:28:45 +0200
committerMarius Halden <marius.h@lden.org>2018-06-07 13:28:45 +0200
commit956f8b8a065824f9a9dc379eba1d0aa8b1b669cf (patch)
tree49f9ccb147b18dddee97500d4df7a3fb3dd3737c /perllib/FixMyStreet/App/Controller/FakeMapit.pm
parent782457d016084c8de04989dbc824a71899f8b41b (diff)
parent4dbf5371f79c5f290c08e561ba2c881e96b58669 (diff)
Merge tag 'v2.3.3' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/FakeMapit.pm')
-rwxr-xr-xperllib/FixMyStreet/App/Controller/FakeMapit.pm16
1 files changed, 14 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/FakeMapit.pm b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
index 0ec13ebfa..51975254a 100755
--- a/perllib/FixMyStreet/App/Controller/FakeMapit.pm
+++ b/perllib/FixMyStreet/App/Controller/FakeMapit.pm
@@ -2,7 +2,7 @@ package FixMyStreet::App::Controller::FakeMapit;
use Moose;
use namespace::autoclean;
use JSON::MaybeXS;
-use LWP::Simple;
+use LWP::UserAgent;
BEGIN { extends 'Catalyst::Controller'; }
@@ -22,13 +22,25 @@ world is one area, with ID 161 and name "Everywhere".
my $area = { "name" => "Everywhere", "type" => "ZZZ", "id" => 161 };
+has user_agent => (
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $ua = LWP::UserAgent->new;
+ my $api_key = FixMyStreet->config('MAPIT_API_KEY');
+ $ua->agent("FakeMapit proxy");
+ $ua->default_header( 'X-Api-Key' => $api_key ) if $api_key;
+ return $ua;
+ }
+);
+
# The user should have the web server proxying this,
# but for development we can also do it on the server.
sub proxy : Path('/mapit') {
my ($self, $c) = @_;
(my $path = $c->req->uri->path_query) =~ s{^/mapit/}{};
my $url = FixMyStreet->config('MAPIT_URL') . $path;
- my $kml = LWP::Simple::get($url);
+ my $kml = $self->user_agent->get($url)->content;
$c->response->body($kml);
}