hesco has asked for the wisdom of the Perl Monks concerning the following question:
I have a module which looks something like this:
I'm running tests on this module which look like this:package MyApp::RESTful; use warnings; use strict; use REST::Application; use base 'REST::Application'; sub new { my $self = shift; my $args = shift; my $app = {}; $app->{'dbh'} = DBI->connect(); $app->{'cfg'} = Config::Simple->new(); $app->{'__defaultQuery'} = CGI->new(); . . . . . . bless $app, $self; return $app; } sub setup { my $self = shift; $self->resourceHooks( qr{/sd/agent/create/(.*)$} => '_AgentCreate', qr{/sd/agent/password/change/(.*)$} => '_AgentPWChange', qr{/sd/agent/logout/(.*)$} => '_AgentLogOut', qr{/sd/agent/stats/(.*)$} => '_AgentJobStats', qr{/sd/agent/authentication/(.*)$} => '_AgentAuthenticate' ); }
which seems to indicate that $myapp can perform all of the methods in its base class REST::Application. But for some reason, it does not seem to be running the handler specified in my setup() call. It does seem to be running both preRun() and postRun() just fine, but I'm not seeing callHandler() do its thing with my custom code identified in the call to ->resourceHooks().my @REST_methods = qw( new query defaultQueryObject resourceHooks extr +aHandlerArgs getPathInfo getRealRequestMethod getRequestMethod loadRe +source getHandlerArgs callHandler getMatchText checkMatch getLastMatc +hPath getLastMatchPattern run getHeaders addRepresentation headerType + header resetHeader setRedirect setup preRun postRun defaultResourceH +andler _getHandlerFromHook makeHandlerFromRef makeHandlerFromClass be +stContentType simpleContentNegotiation scoreType getContentPrefs getA +cceptHeader _getLastRegexMatches _setLastRegexMatches ); foreach my $method ( @REST_methods ){ can_ok($myapp, $method); }
I have not found much literature on this module beyond the perldoc. Are folks actually using REST::Application and if so, can anyone advise me how to make it work, please?
-- Hugh
UPDATE:
I also wrote the author asking the following:
Does REST::Application still only work with Apache 1.3, as suggested in the article here: http://perlmonks.com/?node_id=562705
Is it safe to assume that if I'm not using mod_perl, but cgi instead that I don't need:
use Apache; use Apache::Constants qw(:common); sub handler { __PACKAGE__->new(request => $r)->run(); return OK; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: REST::Application not finding handler
by Anonymous Monk on Aug 18, 2009 at 01:47 UTC |