Reputation: 24518
I'm cutting my teeth on Akka HTTP by working this example. For the purposes of learning, I converted it to a Maven project. However, I'm getting compilation errors as follows using Akka v2.3.12 and Akka Stream v1.0. The POST DSL fails with similar errors that I'm not posting for brevity. How can I get the example to run?
pathPrefix("ip") {
(get & path(Segment)) { ip =>
complete {
fetchIpInfo(ip).map[ToResponseMarshallable] {
case Right(ipInfo) => ipInfo
case Left(errorMessage) => BadRequest -> errorMessage
}
}
}
[ERROR] found : akka.http.scaladsl.server.Directive[(String,)]
[ERROR] required: ?{def apply: ?}
[ERROR] Note that implicit conversions are not applicable because they are ambiguous:
[ERROR] both method addDirectiveApply in object Directive of type [L](directive: akka.http.scaladsl.server.Directive[L])(implicit hac: akka.http.scaladsl.server.util.ApplyConverter[L])hac.In => akka.http.scaladsl.server.Route
[ERROR] and method fromDirective in object ConjunctionMagnet of type [L, R](other: akka.http.scaladsl.server.Directive[R])(implicit join: akka.http.scaladsl.server.util.TupleOps.Join[L,R])akka.http.scaladsl.server.ConjunctionMagnet[L]{type Out = akka.http.scaladsl.server.Directive[join.Out]}
[ERROR] are possible conversion functions from akka.http.scaladsl.server.Directive[(String,)] to ?{def apply: ?}
[ERROR] (get & path(Segment)) { ip =>
error: akka.http.scaladsl.server.Directive[(String,)] does not take parameters
[ERROR] (get & path(Segment)) { ip =>
Upvotes: 1
Views: 761
Reputation: 24518
Turns out this is due to the deep implicit
chain that Spray (and hence akka-http) uses so getting the imports right is crucial. Very few examples show the imports and those that do, use old libraries.
Upvotes: 1