Re: Delayed compilation of routes (defroutes)

43 views
Skip to first unread message

James Reeves

unread,
Feb 19, 2013, 2:56:59 AM2/19/13
to Compojure
You can delay evaluation of routes the same as you can delay any block of code. You currently have:

  (defroutes hs-routes ...)

Which is equivalent to:

  (def hs-routes (routes ...))

So you could wrap it in a function:

  (defn create-hs-routes [] (routes ...))

Or use a delay:

  (def hs-routes (delay (routes ...)))

- James


On 19 February 2013 00:09, Dima B <dima...@gmail.com> wrote:
Hi,

I'm using (defroutes hs-routes ...) to specify routes and while defining these routes I reference some configuration parameters coming from configuration files and command line parameters.
It looks like (defroutes ...) gets compiled before the main method has a chance to run. As a result, all configuration values are nil at that point.

What is the recommended way to delay the compilation of routes till the point when configuration files are properly initialized by the main method (some arguments come from the command line parameters)?

Thank you,
Dima

--
You received this message because you are subscribed to the Google Groups "Compojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to compojure+...@googlegroups.com.
To post to this group, send email to comp...@googlegroups.com.
Visit this group at http://groups.google.com/group/compojure?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dima B

unread,
Feb 19, 2013, 10:44:58 PM2/19/13
to comp...@googlegroups.com, ja...@booleanknot.com

Much appreciated, you're the man!
Reply all
Reply to author
Forward
0 new messages