I am defining some paths but then i run into this error for the tilde ~ right before " pathPrefix(start)" . I am a bit new in Scala and so something do not click right away. thanks
not found:value ~
Is it because i need to define a function? If so why?
import
akka.http.scaladsl.marshallers.xml.ScalaXmlSupport.defaultNodeSeqMarshaller
import akka.http.scaladsl.server.{ HttpApp, Route }
import akka.http.scaladsl.model.StatusCodes
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.typesafe.config.ConfigFactory
import akka.event.Logging
import akka.http.scaladsl.model._
object ABC extends HttpApp with App {
implicit val actorSystem = ActorSystem()
implicit val matter = ActorMaterializer()
val start = "hello"
val Routing= {
path(start) {
redirect( Uri(start+ "/index.html"), StatusCodes.PermanentRedirect )
}
~
pathPrefix(start) {
content
}
}
val content =
{
get
{
path("html") {
getFromResource("src/html") }
}
}
}
Once you added the import as per @chunjef answer, also note that ~
is an infix operator, so it comes with all the "quirks" of it.
To sort out your routes, you can avoid placing the ~
in a new line
val Routing= {
path(start) {
redirect( Uri(start+ "/index.html"), StatusCodes.PermanentRedirect )
} ~
pathPrefix(start) {
content
}
}
or you can wrap the concatenated routes in brackets
val Routing= {
(path(start) {
redirect( Uri(start+ "/index.html"), StatusCodes.PermanentRedirect )
}
~
pathPrefix(start) {
content
})
}