You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Dunlap <jo...@lariat.co> on 2014/02/08 20:59:50 UTC

Is this something which would interest anyone?

I've been working in mod_perl for almost a year now and something which I
struggled with, at first, was request routing. The application that I
maintain uses a simple hash lookup using $r->uri as the key to the
package/method name which should be invoked to respond to the request. I
really disliked the inflexibility of this approach so I've since developed
a more flexible(recursive) lookup mechanism which allows me to use restful
uri's which include path parameters. For example, this code allows me to do
things like this,

my $registry = ServiceRegistry->new;
$registry->register('SERVICE1', '/api/rest/service1/{param1}/list');
my $service = $registry->find($r->uri); # $r->uri returns
'/api/rest/service1/5732/list'
print "$service\n"; # Prints "SERVICE1"
my $parameters = $registry->extract_parameters($r->uri); # $r->uri returns
'/api/rest/service1/5732/list'
print $parameters->{'param1'} . "\n"; # Prints 5732

In this example, I'm registering a scalar, for simplicity, but you can
register anything(array, hashes, objects, etc). It would take me a little
time to clean it up and package it in a way which would be useful to others
but, before I go to that trouble, I just wanted to ask if anyone would be
interested in my releasing this module on CPAN?

John

Re: Is this something which would interest anyone?

Posted by Marius Gavrilescu <ma...@ieval.ro>.
John Dunlap <jo...@lariat.co> writes:

> I just wanted to
> ask if anyone would be interested in my releasing this module on CPAN?

What are the differences between this module and Router::Simple [0]? As
the basic idea is the same, it might be better to patch Router::Simple
to include the features your module has and Router::Simple doesn't. You
could then submit your patch as a pull request to [1].

[0]: https://metacpan.org/pod/Router::Simple
[1]: https://github.com/tokuhirom/p5-router-simple
-- 
Marius Gavrilescu