A while back I got a bunch of great help with combining the web framework Twain with postgresql-simple - so tonight I converted my small web-app from Spock to Twain, and it seems to have gone quite well, everything is working.
Well, except for one thing - routes that end with “/”. If make a route like this in Spock:
get "about" about
It matches both https://example.org/aboutandhttps://example.org/about/ - which is what I want.
When I make a route like this in Twain:
, get "about" (about state pool)
it only matches https://example.org/about, and what’s worse: I cannot make Twain match https://example.org/about/(!) Eg going get "about/" (about state pool) doesn’t match, neither does get "/about/", so I am at a loss.
I could perhaps do some trickery in Apache, but I’d really rather like the framework to keep handling this.
The only workaround I have found so far is:
, get "/about/:wat" (about state pool)
but that feels kind of ugly. Especially when I want, say, a word-cloud of all keywords on /keyword/ (so one function) and a list of articles matching a specific keyword on /keyword/programming (another function), for instance.