Siva Kumar Siva Kumar - 1 year ago 212
Scala Question

found : akka.http.scaladsl.server.StandardRoute [error] required: scala.util.Try

I am new to Scala and to akka i am trying to publish endpoint. Following compilation error is occurring.

found: akka.http.scaladsl.server.StandardRoute
[error] required: scala.util.Try[Option[com.activegrid.entities.AuthSettings]] => (akka.http.scaladsl.server.RequestContext => scala.concurrent.Future[akka.http.scaladsl.server.RouteResult])

Case class

case class AuthSettings(authType:String,authLevel:String,scope:String);


pathPrefix("config") {
path("settings"/"auth") {
post {
entity(as[AuthSettings]) { authSettings =>
val save: Future[AuthSettings] = persistance.persistAuthSettings(authSettings)
onComplete(save) {
complete("To insert app settings")

persistAuthSettings definition

def persistAuthSettings(authSettings: AuthSettings) : Future[AuthSettings] = Future {
//Neo4j Operations


What is going wrong in my code?

Answer Source

onComplete extracts the value from the future, and requires a function which operates on this value:

onComplete(save) { appSettings =>
  complete("To insert app settings")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download