Hi, I'm currently learning racket, and started developing a web application. When using dispatch-rules, my first thought was to create separate dispatch rules and then call them from a top dispatch. Something like this:
(dispatch-rules (("admin") admin-dispatch) (("api") api-dispatch) ... other rules) (define-values (admin-dispatch admin-url) ("" admin-index) ...) (define-values (api-dispatch api-url) ("" api-index) ...) If I understand correctly there's no simple direct way to do this. I managed to do it the following way: - defining the top level dispatch with string-arg's to catch all requests, and wrapping the dispatch function to use only the first argument (the request) (define-values (top-dispatch top-url) (dispatch-rules (("admin") (string-arg) ...) (lambda args (admin-dispatch (first args)))))) - defining the other dispatch functions with the sub-path repeated (define-values (admin-dispatch admin-url) (dispatch-rules (("admin" "posts") admin-posts))) My questions: - is there an existing way to create this kind of cascading or nested dispatch rules? - is there a parameter matcher to match anything that I could use instead of (("path") (string-arg) ...) (lambda args (path-dispatch (first args)))) or some better way to match everything starting with "path"? If there is no way I'm thinking of creating a macro to simplify, so that I don't need wrapping the dispatch functions, specifying parameters and then discarding and so on. Thanks, André
____________________ Racket Users list: http://lists.racket-lang.org/users