On 18 October 2010 19:06,  <lprefonta...@softaddicts.ca> wrote:
> The routes are the following (after several attempts with the file wrapper):
>
> (defroutes app-routes
>   (GET "/patient" [patient-id]
>     (render-page "Dossier médical") (render-page (load-patient-mr 
> patient-id)))
>  (GET "/req" req (str req))
>  (GET "/file" [] (doto (java.io.File. ".") (.getAbsolutePath)))
>  (GET "/" [] (render-page "Saisie du # de patient" patient-form))
>  (route/not-found "Page inconnue")
> )

There's a function called compojure.route/files that is designed to
serve static files from a directory:

  (defroutes app-routes
    (GET "/patient" [patient-id]
      (do-something))
    (route/files "/")
    (route/not-found "Page inconnue"))

The route/files function serves files from "./public" by default, but
you can change this by specifying the :root option:

  (route/files "/" {:root "./static"})

You can also serve files from resources, using compojure.route/resources:

  (route/resources "/")

Like route/files, you can change the root prefix with :root. By
default, it looks in "/public", so if you're using Leiningen, you can
put your files in "./resources/public".

Note that route/resources doesn't support index files (e.g. "/foo/"
becomes "/foo/index.html").

I'll write all this up on the Compojure wiki. My attention has been on
the Ring documentation lately, so I haven't done much on Compojure.

- James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to