Reputation: 4571
I am designing simple endpoint, where some request can contain param
either as a query param or part of the form body. Any hints how to solve it - does spray support such a use cases? If both are missing proper error should be returned.
Of course I could do it by myself just checking for the existence of both of them, and then choosing one or raising exception if both missing, but hope that framework can do it nicer!
Upvotes: 0
Views: 56
Reputation: 1019
Yes spray supports it via anyParams
directive! Here is link to documentation: http://spray.io/documentation/1.2.3/spray-routing/any-param-directives/anyParams/
And here is an example from documentation
val route =
anyParams('name, 'age.as[Int])((name, age) =>
complete(s"$name is $age years old")
)
Upvotes: 1