Re:Detailed Breakdown of a Clojure Web App
by nonrecursive on Saturday November 10, 2012 @09:51PM
(#4768608)
Thank you! And thank you for making such great libraries available.
For #1, I definitely started by not passing the full request map but I ended up finding it cumbersome. On the other hand, my code doesn't really need the full request map. I'll have another go at it and see how I can improve things - thanks for the guidance. It feels like a process of over-contraction, then over-expansion. Hopefully I'll find a happy medium.
For #2 - thank you! I was trying to work toward something like but couldn't quite get there, so this is great.
Re:Detailed Breakdown of a Clojure Web App
by weavejester on Sunday November 11, 2012 @05:50AM
(#4769213)
Could you give me an example of a route that was particularly messy if you didn't pass the full request map? Maybe I can suggest a better option (or at least admit defeat :)
Re:Detailed Breakdown of a Clojure Web App
by nonrecursive on Sunday November 11, 2012 @12:24PM
(#4769990)
You know, I actually can't think of any. I just ended up writing things the way I did because I anticipated I would want the full request map, but that assumption hasn't born out. Passing params might be a good way to go. I need to go back and change this!
1. If you return a handler function from a Compojure route, the handler is evaluated with the request. So:
Is the same as: So there's no need for a separate "route" macro.However, passing the full request map is discouraged, because the more information you give a function, the more things can theoretically affect it. Functions should be limited in what they know and what they can do, and this is one of the principles Compojure is designed around.
2. Some of the macros you've written for Korma could be written as functions instead. For example: