]> git.evergreen-ils.org Git - working/NCIPServer.git/blob - NCIPResponder.pm
This is my start to the NCIPServer, the only real code is the Apache NCIPResponder...
[working/NCIPServer.git] / NCIPResponder.pm
1
2 package NCIPServer::NCIPResponder;
3 use strict;
4 use warnings;
5
6 use FileHandle;
7
8 use Apache2::Const -compile => qw(OK :log :http :methods :cmd_how :override);
9 use Apache2::RequestRec ();
10 use Apache2::RequestIO ();
11 use NCIPServer::NCIP;
12
13 sub handler {
14   my $r = shift;
15
16   return Apache2::Const::HTTP_METHOD_NOT_ALLOWED unless $r->method_number eq Apache2::Const::M_POST;
17
18   my $NCIPConfigFile = $r->dir_config('NCIPConfigFile');
19
20   if (!defined($NCIPConfigFile)) {
21     die sprintf "error: There is no NCIPConfigFile defined\n";
22   } else {
23     if (! (-r $NCIPConfigFile)) {
24       die sprintf "error: NCIPConfigFile %s does not exist or is not readable\n", $NCIPConfigFile;
25     }
26   }
27
28   my $ncip = NCIPServer::NCIP->new($NCIPConfigFile);
29
30   $r->content_type('text/html');
31   my $tmp_buf;
32   my $input_xml;
33
34   while ($r->read($tmp_buf, 1024))
35   { 
36     $input_xml .= $tmp_buf;
37   }
38
39   my $response_xml = $ncip->process_request($input_xml);
40
41   $r->print($response_xml);
42   return Apache2::Const::OK;
43 }
44
45 1;