From 25468fa7e64263758f6b3d5741802ac462e029f9 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Thu, 2 Jun 2011 13:03:22 -0400 Subject: [PATCH] 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 --- .../perlmods/lib/OpenILS/WWW/AddedContent/OpenLibrary.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 ) = @_; -- 2.11.0