From: Dan Scott Date: Thu, 2 Jun 2011 17:03:22 +0000 (-0400) Subject: Support proxying bulk Read API requests for access rights X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=25468fa7e64263758f6b3d5741802ac462e029f9;p=contrib%2FConifer.git Support proxying bulk Read API requests for access rights Using IP-based access right determination runs into problems with a pure JavaScript API, as users may be accessing the API from any location in the world. Proxying the requests via the library system server ensures that the access rights for users of those libraries are properly displayed. Signed-off-by: Dan Scott Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm index 3bdaf6a96e..32a035015d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm @@ -28,7 +28,8 @@ use Data::Dumper; my $AC = 'OpenILS::WWW::AddedContent'; -my $blank_img = 'http://images.concat.ca/opac/images/blank.png'; +# This should work for most setups +my $blank_img = 'http://localhost/opac/images/blank.png'; # This URL is always the same for OpenLibrary, so there's no advantage to # pulling from opensrf.xml @@ -240,6 +241,16 @@ sub send_html { return { content_type => 'text/html', content => $HTML }; } +# proxy OpenLibrary requests so that the IP address of the library +# can be used to determine access rights to materials +sub proxy_json { + my( $self, $key ) = @_; + + my $url = $read_api . $key; + $self->send_json($AC->get_url($url)->content()); +} + + # returns the HTTP response object from the URL fetch sub fetch_response { my( $self, $key ) = @_;