spray/spray — pull request #142 by agemooij (2012-10-11 13:17:05+00:00)
Title: First (failing) attempt at fixing a problem with headerValue

The problem is that Spray (Routing) does not give any feedback if you require a header using the headerValue directive and that header does not exist. The scaladoc comments say that the function should produce a MissingHeaderRejection in such cases but that class does not exist and instead it produces an empty Rejection list. I ran into this when writing a test for my route handler.

I tried to make this work by adding the class and producing it in the correct cases, but I ran into some problems:

- There is no way to get the name of the missing header (I inserted a placeholder string for now)
- The cookie directive test now fails because it uses headerValue internally and thus an unexpected extra Rejection is produced

I think a better solution would be to add another, more highLevel directive to mandate headers being present purely by header name (instead of a hard/cumbersome to use function value) and to make the lower level directive private (or inline it into the cookie directive, or make it sufficiently different in name).

I'm curious what you guys think.

Regards,
Age