Routing, using ring.middleware.params and net.cgrand.moustache:
----
(def tlog-app-handler
(app ["admin" &]
{:get (app ...snip...)
:post (app wrap-params [[path not-empty] &] submit-article)}
----
Thanks to wrap-params, I can destructure request params within
submit-article. However, I also want to have "path". Without
wrap-params, it would simply be:
----
(app [[path not-empty] &] (submit-article path))
----
----
(app wrap-params [[path not-empty] &] (partial submit-article path))
----
results in "nth not supported on this type: PersistentHashMap"
assoc-param (see
http://mmcgrana.github.com/ring/middleware.params-api.html) looks like
it could be what I need, but I can't find out how to use it in this
context (what wraps what and what is the right "map"?)
I realize that I could extract "path" from the request map, but I would
prefer a solution where what has been taken apart already is used,
instead of repeating that work.
--
Thorsten Wilms
thorwil's design for free software:
http://thorwil.wordpress.com/
Should have been:
----
(app [[path not-empty] &] (wrap-params (partial submit-article path)))
----
Which works, then.
Thanks to the fine folks in #clojure, I have another solution:
----
(app [[path not-empty] &] (wrap-params
(fn [req] (submit-article req path))))
----