librelist archives

« back to archive

redirect routes?

redirect routes?

From:
Ryan Kelly
Date:
2011-01-27 @ 05:35
Hi All,


  I am trying to translate some of my apache config files into mongrel2
and am looking for the equivalent of apache's "Redirect" and/or
"RedirectMatch" directives.  I don't see any mention of redirects in the
mongrel2 book, so I assume they're not supported from within mongrel2
itself?

  It seems easy enough to write a custom redirect handler to dispatch
them, but would there be any interest in adding a native Redirect item
to the mongrel config?  Something like this:

    #  Make sure everyone's on the full domain
    Host(name="example.com",routes={
        "/":  Redirect(location="www.example.com")
    })


  Might be a nice task for me to hack on while getting familiar with the
mongrel2 code.

  Of course, having too many different kinds of end-point in the config
language is probably a bad thing.  Any alternate suggestions?


  Cheers,

     Ryan

-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
ryan@rfk.id.au        |  http://www.rfk.id.au/ramblings/gpg/ for details

Re: [mongrel2] redirect routes?

From:
Zed A. Shaw
Date:
2011-01-27 @ 08:48
On Thu, Jan 27, 2011 at 04:35:42PM +1100, Ryan Kelly wrote:
> 
> Hi All,
> 
>   I am trying to translate some of my apache config files into mongrel2
> and am looking for the equivalent of apache's "Redirect" and/or
> "RedirectMatch" directives.  I don't see any mention of redirects in the
> mongrel2 book, so I assume they're not supported from within mongrel2
> itself?

Yep, nothing like that in the code yet.

>   It seems easy enough to write a custom redirect handler to dispatch
> them, but would there be any interest in adding a native Redirect item
> to the mongrel config?  Something like this:

Definitely could be needed, but I'd make it more general:

#  Make sure everyone's on the full domain
Host(name="example.com",routes={
    "/":  Response(
        code=301, status="Moved Permanently", headers = {
        Location="www.example.com"
       })
})

Then it's trivial to make a bunch of canned responses, give out static
replies, etc.

If you want to hack on it, I'd say make a handler that does these first
to figure out how it'd work, then it's probably just a special handler.

The other option is I get off my butt and write the damn
modules/filters/features so that you can do all sorts of crazy stuff
like this. :-)

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] redirect routes?

From:
Ryan Kelly
Date:
2011-01-27 @ 10:02
On Thu, 2011-01-27 at 00:48 -0800, Zed A. Shaw wrote:
> On Thu, Jan 27, 2011 at 04:35:42PM +1100, Ryan Kelly wrote:
> > 
> > Hi All,
> > 
> >   I am trying to translate some of my apache config files into mongrel2
> > and am looking for the equivalent of apache's "Redirect" and/or
> > "RedirectMatch" directives.  I don't see any mention of redirects in the
> > mongrel2 book, so I assume they're not supported from within mongrel2
> > itself?
> 
> Yep, nothing like that in the code yet.
> 
> >   It seems easy enough to write a custom redirect handler to dispatch
> > them, but would there be any interest in adding a native Redirect item
> > to the mongrel config?  Something like this:
> 
> Definitely could be needed, but I'd make it more general:
> 
> #  Make sure everyone's on the full domain
> Host(name="example.com",routes={
>     "/":  Response(
>         code=301, status="Moved Permanently", headers = {
>         Location="www.example.com"
>        })
> })
> 
> Then it's trivial to make a bunch of canned responses, give out static
> replies, etc.
> 
> If you want to hack on it, I'd say make a handler that does these first
> to figure out how it'd work, then it's probably just a special handler.

Yep, I'll definitely make it as a separate handler first so I can have
it up and running.

> The other option is I get off my butt and write the damn
> modules/filters/features so that you can do all sorts of crazy stuff
> like this. :-)

Heh, I've heard people accuse you of a lot of things, but I don't think
"not getting off your butt" is one of them :-)

I've seen some references to these notions of modules/filters in various
mongrel2 discussions, but nothing specific.  Do you have any concrete
ideas jotted down that we can ponder over?  I'd be interested to see
what you have in mind.


  Cheers,

     Ryan

-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
ryan@rfk.id.au        |  http://www.rfk.id.au/ramblings/gpg/ for details