diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-10 14:56:00 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-10 14:56:00 +0100 |
commit | 391ca1c469d93bb2c4798cc15e56fc495b5e80dd (patch) | |
tree | 6bc90fae589de824095e668fbf510ef259935729 /perllib/FixMyStreet/App/Controller/Tilma.pm | |
parent | 7c96f8ec61d6eddc211f3f0e71cdb276c6a5f773 (diff) | |
parent | 860383f0de3287b0666d64a3ffff3db3a0f087ae (diff) |
Merge branch 'migrate_to_catalyst' into reportemptyhomes
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Tilma.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tilma.pm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Tilma.pm b/perllib/FixMyStreet/App/Controller/Tilma.pm new file mode 100644 index 000000000..1be481949 --- /dev/null +++ b/perllib/FixMyStreet/App/Controller/Tilma.pm @@ -0,0 +1,46 @@ +package FixMyStreet::App::Controller::Tilma; +use Moose; +use namespace::autoclean; + +BEGIN { extends 'Catalyst::Controller'; } + +use LWP::UserAgent; + +=head1 NAME + +FixMyStreet::App::Controller::Tilma - Tilma proxy + +=head1 DESCRIPTION + +A tilma proxy - only intended to be used during dev. In production the webserver should do this proxying. + +=head1 METHODS + +=head2 default + +Proxy everything through to the tilma servers. + +=cut + +sub default : Path { + my ( $self, $c ) = @_; + + my $path = $c->req->uri->path_query; + $path =~ s{/tilma/}{}; + + my $tilma_uri = URI->new("http://tilma.mysociety.org/$path"); + + my $tilma_res = LWP::UserAgent->new->get($tilma_uri); + + if ( $tilma_res->is_success ) { + $c->res->content_type( $tilma_res->content_type ); + $c->res->body( $tilma_res->content ); + } + else { + die sprintf "Error getting %s: %s", $tilma_uri, $tilma_res->message; + } +} + +__PACKAGE__->meta->make_immutable; + +1; |