With "web-server", does anyone have a preferred way of making "dispatch-rules" handle slashes at the ends of URLs?

For example, if I have a URL "/foo", I'd like to also accept "/foo/" for the same behavior.

So, I could do something like this:

(define-values (app-dispatch app-url)
  (dispatch-rules
   (()         handle-home)
   (("")       handle-home)
   (("foo")    handle-foo)
   (("foo" "") handle-foo)
   (("bar")    handle-bar)
   (("bar" "") handle-bar)))

But I'd like to canonicalize either "/foo" or "/foo/", and have its counterpart do an HTTP permanent redirect to the canonical one. (Apache does this in some cases, for example.)

So, to canonicalize, I could just add to the "dispatch-rules" a bunch of rules to procedures like "handle-foo/non-canonical-url", which do "(redirect-to URL permanently)". But I was wondering whether there was already a slicker way of doing this.

Neil V.

____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to