Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Single PerlResponseHander for Web Application

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


online.jerry at gmail

Jul 18, 2011, 3:02 PM

Post #1 of 6 (823 views)
Permalink
Single PerlResponseHander for Web Application

Hi,

I am new to mod_perl and would like to get some suggestion on my current
application design.

Following is the design:

Single PerlResponseHandler for my application, all requests will be
submitted to this handler, the handler will then dispatch the request to
appropriate sub-handlers based on the URI path.
Note: My path and handler mapping will be stored in a configuration file.

My configuration will look as follows -

<Location /app>
SetHandler modperl
PerlResponseHandler MyPackage::MyHandler
PerlAuthenHandler MyPackage::MyAuthHandler
</Location>


Psudocode in MyPackage::MyHandler:

------------------------------------

sub handler {
.....
.....

//Get the handler based on path
$sub_handler = getHandler($uripath) //e.g. /app/users
$sub_handler->handle($r, $session);
}

Please let me know of your views. I am not planning to use Catalyst or
existing frameworks as of now. I also thought of using Apache2::Dispatch,
but i believe it requires that each path has its own handler configured in
httpd.conf file (please correct me if I am wrong)

Thanks,
Jerry


perrin at elem

Jul 18, 2011, 3:27 PM

Post #2 of 6 (786 views)
Permalink
Re: Single PerlResponseHander for Web Application [In reply to]

On Mon, Jul 18, 2011 at 6:02 PM, Jerry Pereira <online.jerry [at] gmail> wrote:
> Single PerlResponseHandler for my application, all requests will be
> submitted to this handler, the handler will then dispatch the request to
> appropriate sub-handlers based on the URI path.

Sounds like Apache2::Dispatch to me.

> I also thought of using Apache2::Dispatch,
> but i believe it requires that each path has its own handler configured in
> httpd.conf file (please correct me if I am wrong)

You're confused about this one. Eliminating the need to add each
class to httpd.conf is the main reason that Dispatch exists.

- Perrin


davehodg at gmail

Jul 19, 2011, 2:55 AM

Post #3 of 6 (774 views)
Permalink
Re: Single PerlResponseHander for Web Application [In reply to]

On 18 Jul 2011, at 23:02, Jerry Pereira wrote:

> Please let me know of your views. I am not planning to use Catalyst or existing frameworks as of now.

Any reason? There are lightweight ones that play well with modern approaches
to plugins and multi-server environments.


online.jerry at gmail

Jul 19, 2011, 9:55 AM

Post #4 of 6 (780 views)
Permalink
Re: Single PerlResponseHander for Web Application [In reply to]

I agree, but isn't the Handler tightly coupled to the URI? rather if i can
configure the mapping of URI and sub-handlers in a different configuration
file or database, it will be easier to handle URI changes.


On Mon, Jul 18, 2011 at 3:27 PM, Perrin Harkins <perrin [at] elem> wrote:

> On Mon, Jul 18, 2011 at 6:02 PM, Jerry Pereira <online.jerry [at] gmail>
> wrote:
> > Single PerlResponseHandler for my application, all requests will be
> > submitted to this handler, the handler will then dispatch the request to
> > appropriate sub-handlers based on the URI path.
>
> Sounds like Apache2::Dispatch to me.
>
> > I also thought of using Apache2::Dispatch,
> > but i believe it requires that each path has its own handler configured
> in
> > httpd.conf file (please correct me if I am wrong)
>
> You're confused about this one. Eliminating the need to add each
> class to httpd.conf is the main reason that Dispatch exists.
>
> - Perrin
>



--
Your clothes may be the latest in style but you aint completely dressed
until you wear a smile!
Keep smiling : )


perrin at elem

Jul 19, 2011, 10:46 AM

Post #5 of 6 (775 views)
Permalink
Re: Single PerlResponseHander for Web Application [In reply to]

On Tue, Jul 19, 2011 at 12:55 PM, Jerry Pereira <online.jerry [at] gmail> wrote:
> I agree, but isn't the Handler tightly coupled to the URI?

Yes.

> rather if i can
> configure the mapping of URI and sub-handlers in a different configuration
> file or database, it will be easier to handle URI changes.

I don't see any advantage to doing it in a different config file or
database over just putting it in httpd.conf. Are you thinking you
would avoid restarts? You'd probably want to restart anyway when you
deploy new code.

- Perrin


perrin at elem

Jul 19, 2011, 12:21 PM

Post #6 of 6 (774 views)
Permalink
Re: Single PerlResponseHander for Web Application [In reply to]

On Tue, Jul 19, 2011 at 2:02 PM, Jerry Pereira <online.jerry [at] gmail> wrote:
> Thats right, i was thinking of avoiding restarts and having single place for
> mapping URIs to classes.

You can get that to some degree if you use Apache2::Reload and avoid
doing anything too strange in your code. The thing is, your best
defense against memory bloat is copy-on-write, and that will get
crushed if you do a lot of reloading code without a restart. Maybe
not an issue for you, depending on how big your site is.

- Perrin

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.