Thanks, I'll take a look at pallet. And thanks also to Tassilo for the 
suggestion to use anonymous functions.

--Miikka


On Jan 10, 2012, at 4:36 PM, Sam Ritchie wrote:

> Mikka,
> 
> The pallet/thread-expr library has the macros you're looking for:
> 
> https://github.com/pallet/thread-expr
> 
> These would allow you to write:
> 
> (use 'pallet.thread-expr)
> 
> (-> {}
>    (status code)
>    (content-type "application/json;charset=utf-8")
>    (when-> (= error-type :unauthorized)
>      (header "WWW-Authenticate" "Basic realm=\"my-realm\""))
>    (when-not-> (= request-method :head)
>      (assoc :body (json-str ...))))
> 
> The tests provide a decent set of examples:
> 
> https://github.com/pallet/thread-expr/blob/develop/test/pallet/thread_expr_test.clj
> 
> Cheers,
> Sam
> 
> On Tue, Jan 10, 2012 at 8:06 AM, Miikka Miettinen 
> <miikka.mietti...@gmail.com> wrote:
> Hi,
> 
> I sometimes find myself wanting to write simple conditional expressions 
> inside -> and ->>. For example, it would be nice to create Ring responses 
> like this:
> (-> {}
>    (status code)
>    (content-type "application/json;charset=utf-8")
>    (when (= error-type :unauthorized)
>      (header "WWW-Authenticate" "Basic realm=\"my-realm\""))
>    (when (not= request-method :head)
>      (assoc :body (json-str ...))))
> 
> The above obviously doesn't work, but is there some other macro somewhere 
> that would enable me to do this?
> 
> Best regards,
> Miikka
> 
> --
> 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
> 
> 
> 
> -- 
> Sam Ritchie, Twitter Inc
> 703.662.1337
> @sritchie09
> 
> (Too brief? Here's why! http://emailcharter.org)
> 
> 
> -- 
> 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

-- 
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