snapframework/snap-core — Issue #125: Using serveDirectory can break routing
Author: zopa
Created: 2012-03-09 14:26:13+00:00
State: open

Using `snap init barebones` and this route table:

route [ ("article", serveDirectory "resources/static")
, ("article/:id", writeBS "Why am I here?")
]

a request for "/article" returns "Why am I here?", rather than the expected contents of "resources/static/index.html".

Snap, given a call to `serveDirectory`, appends a trailing slash to the url and then appears to double back through the route table with the new URL; on the second pass "/article/" matches "/article/:id". This is strange: when I route a request to a handler I expect it to stay there, absent an explicit transfer of control.

Replacing `serveDirectory "resources/static"` with `writeBS "index"` outputs "index", as expected.