使用名称中带有破折号的 Akka HTTP 参数

Using Akka HTTP parameters with dashes in their names

我有一些名称中包含破折号的查询参数。当我尝试写类似

的东西时
parameter('name-with-dash.as[String])

...它无法将第一个破折号后的任何内容识别为参数名称的一部分。

添加额外的单引号并不能解决问题:

parameter(''name-with-dash'.as[String])

name-with-dashes 周围使用双引号也不能解决问题,我只是收到 expected ')' 消息,其中 ' 通常在前面。

parameter('"name-with-dash".as[String])

如果我忽略开头的单引号,intellij 不会显示任何错误,但我会收到如下所示的编译错误:

Error:(27, 17) type mismatch; found : String("Name-With-Dash")
required: ?{def as: ?} Note that implicit conversions are not applicable because they are ambiguous:
 both method _string2NR in trait ToNameReceptacleEnhancements of type(string: String)akka.http.scaladsl.common.NameReceptacle[String]
 and method validateModel in object SomeObject of type (value: String)akka.http.scaladsl.server.Directive1[String]
 are possible conversion functions from String("Name-With-Dash") to ?{def as: ?}
      parameter("Name-With-Dash".as[String]).flatMap(p => provide[SomeIdentifier](SomeIdentifier(p))) |

已修复:

已使用以下表格解决此问题

parameter("name-with-dash")

即。只有双引号,没有 .as[String]

一个简单的

parameter("name-with-dash".as[String])

适合我