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 Stauffacher <st...@chapman.edu> on 2002/02/20 03:27:21 UTC

file globbing question

All,

I am a bit confused as to what httpd.conf directives need to be used in
order to get apache to execute a PerlHandler when it encounters a
certain file type. What I want to do:
	Execute a handler whenever a *.qw file is accessed. The same
handler whether or not the file exists and not look for the file. So the
user makes the request: get /somewhere/my.qw and gets the response
"moo". Then they request /other/place/boo.qw and gets the response
"moo". I have tried using a <Files> directive, but it envokes the
handler, then looks for the file and throws a 404. Any ideas?

-John Stauffacher

++
John Stauffacher
Network Administrator
Chapman University
stauffacher@chapman.edu
714-628-7249



Re: file globbing question

Posted by Issac Goldstand <ma...@beamartyr.net>.
It occurred to me that using a scheme like this, it might be possible to 
help improve mod_perl's popularity... Or, at least, the popularity of 
Toolkits built under mod_perl...  Using <Files> (or the 
Apache::MIMEMapper module), makes mod_perl a bit more ISP friendly, as 
it's a lot easier for users to add code to their files...  Maybe using 
Embperl or something like that inside pages...  Anyway, it's just a 
thought...

  Issac

Geoffrey Young wrote:

>Cees Hek wrote:
>
>>On Wed, 2002-02-20 at 13:27, John Stauffacher wrote:
>>
>>>All,
>>>
>>>I am a bit confused as to what httpd.conf directives need to be used in
>>>order to get apache to execute a PerlHandler when it encounters a
>>>certain file type. What I want to do:
>>>      Execute a handler whenever a *.qw file is accessed. The same
>>>handler whether or not the file exists and not look for the file. So the
>>>user makes the request: get /somewhere/my.qw and gets the response
>>>"moo". Then they request /other/place/boo.qw and gets the response
>>>"moo". I have tried using a <Files> directive, but it envokes the
>>>handler, then looks for the file and throws a 404. Any ideas?
>>>
>>The <Files> directive is the right way to go.  Are you sure you are
>>returning OK in your Handler?  If you return something else (like
>>DECLINED) then Apache will take over the request and handle it in the
>>default manner (ie look up the file).  Returning OK lets Apache know
>>that the request was dealt with appropriately and it can move on to the
>>next phase.
>>
>
>another alternative is something like Apache::MIMEMapper...
>
>http://www.modperlcookbook.org/download/Apache-MIMEMapper-0.10.tar.gz
>
>which expands the AddHandler directive to make it a bit more mod_perl
>friendly.
>
>so, instead of using <Files> (which is perfectly legitimate) you can
>instead simply use
>
>AddHandler My::Module .qw
>
>and Apache will use My::Module::handler() for the content-generation
>phase.
>
>all the stuff Cees said it true, though - you still need to make sure
>your handler returns OK and follow the other handler rules. 
>
>HTH
>
>--Geoff
>




Re: file globbing question

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Cees Hek wrote:
> 
> On Wed, 2002-02-20 at 13:27, John Stauffacher wrote:
> > All,
> >
> > I am a bit confused as to what httpd.conf directives need to be used in
> > order to get apache to execute a PerlHandler when it encounters a
> > certain file type. What I want to do:
> >       Execute a handler whenever a *.qw file is accessed. The same
> > handler whether or not the file exists and not look for the file. So the
> > user makes the request: get /somewhere/my.qw and gets the response
> > "moo". Then they request /other/place/boo.qw and gets the response
> > "moo". I have tried using a <Files> directive, but it envokes the
> > handler, then looks for the file and throws a 404. Any ideas?
> 
> The <Files> directive is the right way to go.  Are you sure you are
> returning OK in your Handler?  If you return something else (like
> DECLINED) then Apache will take over the request and handle it in the
> default manner (ie look up the file).  Returning OK lets Apache know
> that the request was dealt with appropriately and it can move on to the
> next phase.
> 

another alternative is something like Apache::MIMEMapper...

http://www.modperlcookbook.org/download/Apache-MIMEMapper-0.10.tar.gz

which expands the AddHandler directive to make it a bit more mod_perl
friendly.

so, instead of using <Files> (which is perfectly legitimate) you can
instead simply use

AddHandler My::Module .qw

and Apache will use My::Module::handler() for the content-generation
phase.

all the stuff Cees said it true, though - you still need to make sure
your handler returns OK and follow the other handler rules. 

HTH

--Geoff

Re: file globbing question

Posted by Cees Hek <ce...@sitesuite.com.au>.
On Wed, 2002-02-20 at 13:27, John Stauffacher wrote:
> All,
> 
> I am a bit confused as to what httpd.conf directives need to be used in
> order to get apache to execute a PerlHandler when it encounters a
> certain file type. What I want to do:
> 	Execute a handler whenever a *.qw file is accessed. The same
> handler whether or not the file exists and not look for the file. So the
> user makes the request: get /somewhere/my.qw and gets the response
> "moo". Then they request /other/place/boo.qw and gets the response
> "moo". I have tried using a <Files> directive, but it envokes the
> handler, then looks for the file and throws a 404. Any ideas?

The <Files> directive is the right way to go.  Are you sure you are
returning OK in your Handler?  If you return something else (like
DECLINED) then Apache will take over the request and handle it in the
default manner (ie look up the file).  Returning OK lets Apache know
that the request was dealt with appropriately and it can move on to the
next phase.

Cees