Is there a simple way to allow only the query parameters specified in a parameters() directive?
I have the following in a route
parameters('limit.as[Int] ? 1000, 'definition.?.as[Option[Long]], 'site.?.as[Option[Long]], 'status.?.as[Option[String]]) { (limit, definition, site, contextStatus) =>
But if I use ?definitionId=123 instead of ?definition=123 the route is accepted and if I don't catch this down the line the user is very confused.
--
You received this message because you are subscribed to the Google Groups "spray.io User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spray-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/spray-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/spray-user/CAKH0pS7x_SyZ_VGvpZgoPZF-PWt%3DSTu33Jv8TPT039t5jzFTcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/spray-user/FA8571EE-7641-453D-87CB-ECC474064DEC%40gmail.com.
What would be really nice is if Spray's RequestContext held a reference to un-matched request parameters in the same way that it holds the un-matched path.
Then you could have multiple nested parameter and parameters directives and a final unmatchedParameters directive that gave you what was left or a rejectIfRemainingUnmatchedParameters.
It looks like that would be a fairly major change to the way that Spray works to support this though,
The only way we could get our code to work was
parameter('example1) { example1 =>
parameter('example2) { example2 =>
parameterMap.require(onlyTheseParams(Set("example1", "example2"))) {
complete("Ok")
}
}
}
private def onlyTheseParams(parameters: Set[String]): (Map[String, String]) => Boolean = {
params => params.keySet.filterNot(parameters).size == 0
}
which is nasty duplication