#!/usr/bin/perl use warnings; use strict; use POE qw( Component::Server::HTTP ); use HTTP::Status; my $VERSION = '0.01'; POE::Component::Server::HTTP->new( Port => 42421, ContentHandler => { "/" => \&uri_handler, }, Headers => { Version => $VERSION }, ); POE::Kernel->run(); sub uri_handler { my ( $request, $response ) = @_; my $path = $request->uri->path; $path =~ s/\W+/_/g; $path = "remote_request".$path; # see update $response->content_type( 'text/plain' ); if ( ! defined &$path ) { $response->code( RC_NOT_FOUND ); return RC_OK; } my $content = eval { no strict 'refs'; &$path }; if ( $@ ) { $response->code( RC_INTERNAL_SERVER_ERROR ); warn $@; $response->content( "ERROR: $@" ); return RC_OK; } $response->code( RC_OK ); $response->content($content); return RC_OK; } sub remote_request_version { return "$VERSION\n" }