Reputation: 1462
I have a simple Akka routes:
pathPrefix("api/games") {
parameters("id".as[String].optional, "name".as[String].optional, "type".as[String].optional ...) { (id, name, type) => {
get {...}
}
}
}
The problem is - I can have different number of optional parameters here. I do not want to pass all of them, because client can send different params. What is the best way to handle them dynamically (based on number of params) in akka-http?
I thought I can add all of them to list and check which are not None
:
val params = List(id, name, type ...)
But I think it is very naive.
Upvotes: 0
Views: 336
Reputation: 2510
parameterMap
may be helpful in your case. It extracts all parameters as Map[String, String]
. Or parameterMultiMap
if some parameter may repeat.
Upvotes: 2