[racket] passing a list of dispatch clauses to dispatch-rules

From: Janos Tobias Locsei (jtlocsei at cantab.net)
Date: Mon Dec 16 17:25:11 EST 2013

Hi, I'm a newbie Racketeer so apologies if this is a silly question:

Is it possible to pass a list of dispatch-clause to dispatch-rules? Naive
use of "apply" doesn't work:

(define-values (blog-dispatch blog-url)
  (let ([arglist
         (list
            [("") list-posts]
            [("posts" (string-arg)) review-post]
            [("archive" (integer-arg) (integer-arg)) review-archive]
            [else list-posts])])
    (apply dispatch-rules arglist)))

(example modified from docs.racket-lang.org/web-server/dispatch.html) This
code gives rise to the error

string-arg: this match expander must be used inside match in: (string-arg)

Maybe there's something clever I could do with delay and force, but I'm not
very familiar with how they work...

Background: the reason I want to do this is so that I can dynamically
construct a list of all the filenames in a directory of static html files
and make dispatch clauses so that they can be accessed at URL's without
".html" on the end.

Thanks in advance for any guidance!

Tobias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131216/7509c317/attachment.html>

Posted on the users mailing list.