[Nitro] New Nitro dispatcher proposal

Jonathan Buch john at oxyliquit.de
Mon Jan 22 05:20:47 EST 2007


Hi,

> At the moment the request uri handling in Nitro is quite simple (but
> surprisingly effective):
>
>
> If the uri containts a '.' (in other words if there is a file extension)
>   -> the request is handled by the front web server.
> If the uri has no extension,
>   -> append the .html extension and check if the file exists
>      - yes? -> the request is handled by the front web server.
>      - no? -> the request is handled by Nitro

This is only true with Webrick (as far as I skimmed the code).

> I propose the following change:
>
> If the uri contains no extension automatically add the .html extension
> Does the file pointed to by the uri exist?
>   - yes ? -> the request is handled by the front web server
>   - no? -> the request is handled by Nitro (append x at the end of the
> extension)

I would rewrite that to:

- Does the file to uri exist?
   - yes : handled by webserver
   - no : handled by nitro
- append .html to uri
   Does the file to uri exist?
   - yes : handled by webserver
   - no : handled by nitro, remove .html
- handle(webserver | nitro) according to above

The 'always append .html' because we can't reliably check what is a file-
extension and what is not, it just doesn't work out in all cases.
Twice (can be reduced in code later) because the file might already be
readily available (1) or only avalable with .html (2).
Those two rules are only neccessary with Mongrel and Webrick, other
webservers (apache/nginx/lightttpd/etc) better provide those checks
themselves in their config files as nitro can't talk to them.

> For example:
>
> if request.uri == index, Nitro searches for
>
>   index -> index.html
>   index.html (front)
>   index.htmlx / index action (nitro)
>   content_type = text/html

How do you translate from .htmlx to 'index' again?  I'm not all so sure
about appending the x behind everything nitro handles..
This would confuse me, if I had no templates and just an action... (Sure
it's only internal, normal developer probably wouldn't even see it.)

> if request.uri == screen.css, Nitro searches for
>
>   screen.css (front)
>   screen.cssx / screen__css action (nitro)
>   content_type = text/css

Isn't __ right now used for / ?  How would you 'choose' between those
modes?

What would happen with types Nitro doesn't recognize as 'templateable'?
Like '.jpg' (maybe dynamic captcha images)?

Would this 'x' appending simplify nitro internal code or would it add
another layer of indirection?

> I would love to hear your thoughts on this new scheme.

Always :P

Hope that helped,

Jo

-- 
Feel the love
http://pinkjuice.com/pics/ruby.png


More information about the Nitro-general mailing list