httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jerome Renard <jerome.ren...@gmail.com>
Subject Re: simple mapping module example?
Date Thu, 29 Apr 2010 07:09:39 GMT
Hello,

On Thu, Apr 29, 2010 at 5:56 AM, Mark Harrison <mh@pixar.com> wrote:
> I would like to do a simple mapper:
>
>   - given some inputs, calculate a file path
>   - let apache serve out that file for me
>
> Is there a simple example of how to do this?  mod_rewrite
> is pretty heavy-duty, and I'd like to get a simpler
> model to follow.

I would have said mod_rewrite is a perfect example of what you can do.

If you look for something smaller, maybe you will find mod_user_dir
easier to read and understand :

- http://svn.apache.org/repos/asf/httpd/httpd/trunk/modules/mappers/mod_userdir.c

>
>
> Here's what I've got so far, am I on the right track?

Could you please post the entire source code so we can help you ?

>
> Many TIA!
> Mark
>
> --------------------------------------------------------------------------------
>
> static int my_mapper(request_rec *r)
> {
>    mypath = lookup(...); <-- e.g. "/usr/mydir/myfile.mp4"

One of http://www.temme.net/sander/api/httpd/http__request_8h.html maybe ?

>
>    ap_set_content_type(r, "video/mp4");
>    apr_table_add(r->headers_out, "Content-disposition",
>                                  "inline; filename=acad.mp4");
>
>
>    ap_???(r, mypath); <-- tell apache we want to serve this file
>                           do this by setting something in r?
>
>    return ???;      <-- tell apache to continue to the next step
>                         and serve out the file

most likely "return OK;" (or return DECLINED; on failure)

> }
>
>
> static void register_mymapper(apr_pool_t *p)
> {
>    ap_hook_translate_name(my_mapper,NULL,NULL,APR_HOOK_MIDDLE);
> }
>
> module AP_MODULE_DECLARE_DATA mymapper_module = {
>    STANDARD20_MODULE_STUFF,
>    NULL,
>    NULL,
>    NULL,
>    NULL,
>    NULL,
>    register_mymapper
> };
>
>
> --
> Mark Harrison
> Pixar Animation Studios
>

Mime
View raw message