Due to security policies we are not allowed to use “underscore” with our imports. Intellij’s scala support is not the best so I had no luck to find the specific import using optional parameters in a http path like:
import akka.http.scaladsl.server.Directives._
val someRoute: Route = {
path("path" / "to" / "resource") {
parameters("color".?) { color =>
... do somthing with it
}
}
optional was only recently introduced, so maybe you just need to use the latest version of Akka HTTP 10.2.0? Both optional and ? are provided by the ParameterDirectives._string2NR implicit conversion.
You can also circumvent explicit imports by using extends Directives or extends ParameterDirectives to get all the necessary symbols in scope (which of course defeats the original purpose of the policy). Optionally you can try to enable wildcard imports in your IDE and only before committing use a refactoring to spell them all out (there’s “Desugar Scala code” in IntelliJ which doesn’t seem to work for me, though?).