0
votes

I have the following piece of code in Scala using Akka HTTP with Spray Routing

import akka.http.scaladsl.server.Directives._

val geoip =
path(RemainingPath) {remaining =>

  val response = . . .

  complete(response)
}

But the I get the error message

[ERROR] FreeGeoIp.scala:45: error: missing parameter type
[ERROR]     path(RemainingPath) {remaining =>
[ERROR]                          ^
[ERROR] one error found

Where exactly is the parameter type supposed to go?

The documentation on this is VERY poor, and according to the examples this code should work.

1
path(RemainingPath) {remaining: MyTypeHere => - Rhys Bradbury
path(RemainingPath) {remaining : String => was my first try, but that does not work either. - Eric Kolotyluk
How is path defined? - Rhys Bradbury
def path[L](pm: PathMatcher[L]): Directive[L] = pathPrefix(pm ~ PathEnd) - Eric Kolotyluk

1 Answers

1
votes

Problem solved. I had too many imports with wildcards. When I reduced the wildcards the problem went away. This set of imports seems to work.

import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpRequest
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.model.Uri.apply
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport.sprayJsonUnmarshaller
import akka.http.scaladsl.marshalling.ToResponseMarshallable.apply
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.unmarshalling.Unmarshal

import akka.stream.scaladsl._

import scala.concurrent.Future

import spray.json._
import spray.json.DefaultJsonProtocol._