<a href="http://docs.racket-lang.org/web-server/run.html#(part._.Examples)">http://docs.racket-lang.org/web-server/run.html#(part._.Examples)</a><div><br></div><div>contains this...</div><div><br></div><div>>>></div>
<div><div>Suppose you wanted it to capture top-level requests:</div><div><br></div><div>(serve/servlet my-app</div><div> #:servlet-regexp #rx"")</div><div><<<</div><div><br></div><div>Where do you think a different example should go? Somewhere on</div>
<div><br></div><div><a href="http://docs.racket-lang.org/web-server/dispatch.html">http://docs.racket-lang.org/web-server/dispatch.html</a></div><div><br></div><div>?</div><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 8:15 PM, Jordan Schatz <span dir="ltr"><<a href="mailto:jordan@noionlabs.com">jordan@noionlabs.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Fri, Dec 02, 2011 at 06:23:38PM -0700, Jay McCarthy wrote:<br>
> The blog-dispatch function returned by dispatch-rules has the contract<br>
> "request? -> response?" so you pass it in in place of "start" to<br>
> serve/servlet:<br>
><br>
> (serve/servlet blog-dispatch ...)<br>
><br>
> It is not a "dispatcher" in the Web server's terminology. That's a<br>
> "connection? request? -> void" function and only low level functions use<br>
> those.<br>
<br>
</div>----------------------------------------------------------------------<br>
#lang web-server<br>
<br>
(require web-server/dispatch<br>
web-server/servlet-env)<br>
<br>
(define-values (blog-dispatch blog-url)<br>
(dispatch-rules<br>
[("") list-posts]<br>
[("posts" (string-arg)) review-post]))<br>
<br>
(define (list-posts req)<br>
(response/xexpr<br>
`(body "list-posts")))<br>
<br>
(define (review-post req p)<br>
(response/xexpr<br>
`(body ,(string-append "review-posts " p))))<br>
<br>
;; ;; Doesn't work<br>
;; (serve/servlet blog-dispatch<br>
;; #:port 8080<br>
;; #:launch-browser? #t)<br>
;; ;; Doesn't work<br>
;; (serve/servlet blog-dispatch<br>
;; #:port 8080<br>
;; #:servlet-path "/"<br>
;; #:launch-browser? #t)<br>
;; Works<br>
(serve/servlet blog-dispatch<br>
#:port 8080<br>
#:servlet-regexp #rx".*" ;But is this "the right way"?<br>
#:launch-browser? #t)<br>
----------------------------------------------------------------------<br>
<br>
Once I got it working, it makes sense; but maybe a more complete example<br>
could be added to the docs?<br>
<br>
Shalom,<br>
<font color="#888888">Jordan<br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jay McCarthy <<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>><br>Assistant Professor / Brigham Young University<br><a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>"The glory of God is Intelligence" - D&C 93<br>
</div>