I'm trying to hook up URL dispatch with Racket (formerly PLT Scheme). I've taken a look at the tutorial and the server documentation. I can't figure out how to route requests to the same servlets.
Specific example:
#lang scheme (require web-server/servlet) (require web-server/dispatch) (provide/contract (start (request? . -> . response/c))) (define (start request) (blog-dispatch request)) (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))) (define (list-posts req) `(list-posts)) (define (review-post req p) `(review-post ,p)) (define (review-archive req y m) `(review-archive ,y ,m)) (require web-server/servlet-env) (serve/servlet start #:launch-browser? #t #:quit? #f #:listen-ip #f #:port 8080 #:extra-files-paths (list (build-path "js") (build-path "css")) #:servlet-path "")
Assuming the above code, localhost:8080/
goes to a page that says "list-posts". Going to localhost:8080/posts/test
goes to a Racket "file not found" page (I'd expect it to go to a page that says "review-post test").
It feels like I'm missing something small and obvious. Can anyone give me a hint?