On Wed, Jan 23, 2013 at 9:29 PM, Limbo Peng <[email protected]> wrote: > Hi all, > > As the Racket Web Server doc shows, we can define URL dispatching rules as > follows: > > (define-values (blog-dispatch blog-url) > (dispatch-rules > [("") list-posts] > [("posts" (string-arg)) review-post] > [("archive" (integer-arg) (integer-arg)) review-archive] > [else list-posts])) > > If I want to make "blog-dispatch" as the only one dispatcher, I can do this: > > (serve/servlet blog-dispatch #:servlet-regexp #rx".*") > > Here's the problem - it captures all requests, including requests to static > files, > which is not what I want - I'd expect that it treats requests that don't match > any rules as a request to a static file in the htdocs/ directory.
I'm not sure why this is a "problem", you wrote in your dispatch an "else" clause that says "All other URLs get passed to list-posts". Why would you expect anything differently? If you remove this 'else' clause, then it will do what you expect, because serve/servlet puts a file server after the servlet server in the dispatch chain. Is there a reason you can't or don't want to do that? Jay > I've found the module "web-server/dispatchers/dispatch-files" that can serve > static files, > but the "make" procedure in it returns a dispatcher, which cannot be passed > to "dispatch-rules" > directly. How can I "convert" it to a normal request handler? > > -Limbo Peng > ____________________ > Racket Users list: > http://lists.racket-lang.org/users -- Jay McCarthy <[email protected]> Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay "The glory of God is Intelligence" - D&C 93 ____________________ Racket Users list: http://lists.racket-lang.org/users

