Conditionally add header?

Greetings –

I’m looking for a way to conditionally add a header (e.g., based on the session containing a certain key). Initially I thought that if the validation fails the header() method becomes a no-op. However that’s not the case:

/* code */
.header(“hdr”, s ⇒ s(“foo”).validate[String])

Yields:

16:44:30.299 [ERROR] i.g.h.a.s.HttpRequestAction - ‘httpRequest-2’ failed to execute: No attribute named ‘foo’ is defined

Could this behavior be accomplished via the public APIs?

Thanks,

-Dragos

I guess you’re actually looking for SignatureCalculator.

Hi Stéphane –

Got it; the form taking an Expression[SignatureCalculator] argument provides just what I was looking for. Thank you for the prompt answer!

-Dragos