鑑於以下途徑呼籲減少對阿卡HTTP路線名單產生編譯錯誤(參數沒有隱含價值加入)
val route1: PathMatcher[Unit] = PathMatcher("app")
val route2: PathMatcher1[String] = PathMatchers.Segment
val route3: PathMatcher[Unit] = PathMatcher("lastSegment")
我可以很容易地定義
val resultingRoute: PathMatcher[Tuple1[String]] = route1/route2/route3
得到預期的類型(的PathMatcher [元組[字符串]])。
但是編程方式創建,如路線
val routeDef = List(route1, route2, route3)
val resultingRoute = routeDef.reduce((a,b) => a/b)
將無法編譯,給我
找不到參數內含價值加盟:akka.http.scaladsl.server.util.TupleOps 。加入[_1,_1]
此外,推斷出的類型的resultingRoute是
PathMatcher[_ >: Unit with Tuple1[String] with join.Out]
我真的很感激任何提示給我一些跡象,說明我在這裏做錯了什麼或者如何解決這個問題。
爲了完整起見,這裏是我的進口:
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.{PathMatcher, _}
非常感謝!
'routeDef'在哪裏定義? –
更新了添加routeDef賦值的問題,謝謝! – evandor