rhibiscusc
(Rhibiscusc)
1
I have a route like /test?format=xx
and parameter format is optional
in scala, I wrote:
path("test") {
parameters("format".optional) {format =>
get {
complete(...)
}
}
But I got the following error:
value optional is not a member of String
parameters(“format”.optional) {format =>
I already imported
import akka.http.scaladsl.server.{Directive0, Directives}
and
import Directives._
what am I missing?
Thanks.
jrudolph
(Johannes Rudolph)
2
Hi @rhibiscusc,
which version of akka-http do you use? optional
has only be introduced recently, I think, in 10.2.0.
Can you check if "format".?
would work?
Johannes
rhibiscusc
(Rhibiscusc)
3
you are right. The version I use is way too old. Thank you!
rhibiscusc
(Rhibiscusc)
4
@jrudolph How should I specify optional parameter with old version 2.4.11? I can’t quite find documentation for this old version. Thanks
rhibiscusc
(Rhibiscusc)
5
I find this documentation: https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/parameter-directives/parameter.html
it seems it does not support optional parameter with 2.4.11.
is there a workaround?
rhibiscusc
(Rhibiscusc)
6
never mind. find it and use .?
Thanks @jrudolph