[plt-scheme] servlet-dispatcher and static files.
Your "start-error" should call (next-dispatcher) to signal to the Web
server to no longer treat the request as a servlet request OR should
reimplement file serving. Obviously it is better to call
(next-dispatcher).
Jay
On Tue, Jan 26, 2010 at 3:23 PM, vannadiz <vika.lapsar at gmail.com> wrote:
> Hello,
> I need to write servlet using *.css files.
> Without dispatchers i have done this in such way.
> (serve/servlet start
> #:extra-files-paths
> (list (build-path my-path "htdocs"))
>
> But when I'm trying this with dispatchers, it doesn't work(css file
> not found) becouse of using #:servlet-regexp #rx""
>
> (serve/servlet start
> #:extra-files-paths
> (list (build-path my-path "htdocs")
> #:servlet-regexp #rx"")
>
> Should I rewrite regexp to stop getting static files into dispatcher
> or maybe there is some better way?
>
> Sample code with static files and servlet-dispatcher below.
>
> #lang scheme
> (require web-server/servlet-env
> web-server/servlet
> web-server/managers/manager)
>
> (define (start-helloworld request)
> '(html
> (link ((rel "stylesheet")
> (href "/gallery.css")
> (type "text/css")))
> (body (div
> ((id "wrap")) "HelloWorld"))))
>
> (define (start-error request)
> '(html
> (link ((rel "stylesheet")
> (href "/gallery.css")
> (type "text/css")))
> (body (div
> ((id "wrap")) "Error"))))
>
> (define-values (servlet-dispatcher generator)
> (dispatch-rules
> [("") start-helloworld]
> [else start-error]))
>
> (define (start req)
> (servlet-dispatcher req))
>
> (serve/servlet start
> #:launch-browser? #t
> #:extra-files-paths
> (list (build-path my-path "htdocs"))
> #:servlet-path "/"
> #:servlet-regexp #rx"" )
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay
"The glory of God is Intelligence" - D&C 93