9 use HTTP::Server::Simple::CGI;
10 use base qw(HTTP::Server::Simple::CGI);
17 '/reviewcert' => \&reviewcert,
18 '/extracerts' => \&extracerts,
25 my $path = $cgi->path_info();
26 my $handler = $dispatch{$path};
28 if (ref($handler) eq "CODE") {
29 # FIXME: ensure that this actually is a POST
30 printf STDERR ("Got POST %s\n", $path);
32 my ($status, $object) = $handler->($cgi);
33 my $ret = to_json($object);
34 printf STDERR ("returning: %s\n", $ret);
35 printf("HTTP/1.0 %s\r\nContent-Type: application/json\r\n\r\n%s", $status, $ret);
38 printf("HTTP/1.0 404 Not Found -- not handled by Monkeysphere validation agent\r\nContent-Type: text/plain\r\n\r\nHTTP/1.0 404 Not Found -- the path:\r\n %s\r\nis not handled by the MonkeySphere validation agent.\r\nPlease try one of the following paths instead:\r\n\r\n%s\r\n", $path, ' * '.join("\r\n * ", keys %dispatch) );
43 my $cgi = shift; # CGI.pm object
46 # open a json blob instead of using CGI params.
47 my $data = from_json($cgi->param('POSTDATA'));
50 print STDERR Dumper($data);
52 my $uid = $data->{context}.'://'.$data->{uid};
54 my $ret = { valid => JSON::true,
55 message => sprintf('tried to validate "%s" through the OpenPGP Web of Trust', $uid) };
56 my $status = '200 match found, authentication details to follow';
64 return '500 not yet implemented', { };
68 # start the server on port 8091
69 my $server = MSVA->new(8901);