I'm working on a small Ring / Compojure webapp, and I'm wondering if there is a way to declutter the routes. I'm using standard Clojure destructuring, but need quite a few arguments passed the the function.
This is OK, using the Compojure Compojure-specific destructuring:
(POST "/login/" [email password] (login-post email password)) ; handle login attempt
Now it starts to get worse. I need to give the function both a flash message and en email stored in a session:
(GET "/login/" {flash :flash {email :email} :session} (login-get flash email))
And here are the route for submitting data through a form:
(POST "/" {{user-email :user-email} :session {title :title} :params {tags :tags} :params { content :content } :params { privacy :privacy } :params} (home-post user-email title tags content privacy))
I know i could just send the raw request to then home-post function using :params, but i somehow feel that that placing the parameter extraction with the routes it a better solution. It make the home-post more pure and easier to test. Instread of just supplying every function with a giant request map.
Can the deconstructing in the routes definition be clearer (more readable), fx using some sort of extract-from-map function, macro, anything?
Pro's and con's for placing the destructuring with the routes?