[racket] Web server and URL dispatch
The blog-dispatch function returned by dispatch-rules has the contract
"request? -> response?" so you pass it in in place of "start" to
serve/servlet:
(serve/servlet blog-dispatch ...)
It is not a "dispatcher" in the Web server's terminology. That's a
"connection? request? -> void" function and only low level functions use
those.
The URLs from blog-url and embed/url (& send/suspend's friends) can be
freely mixed.
Jay
On Fri, Dec 2, 2011 at 6:17 PM, Jordan Schatz <jordan at noionlabs.com> wrote:
> Its unclear to me how to get url dispatch working...
>
> ----------------------------------------------------------------------
> #lang web-server
> (require web-server/templates
> web-server/dispatch
> web-server/web-server)
>
> (define-values (blog-dispatch blog-url) ;;blog-dispatch is our
> ;;new dispatcher?
> (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))
>
> (define (start)
> (serve
> #:dispatch blog-dispatch ;;Start the server with our dispatcher?
> #:port 8080))
>
> (start) ;;Doesn't start a server : (
> ----------------------------------------------------------------------
>
> I cant seem to get a server running that is using that dispatcher... Also
> I presume its possible to mix "pretty" urls made by dispatch-rules and
> embed/url ?
>
> Thanks,
> Jordan
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111202/1977c893/attachment.html>