Siva Kumar
Siva Kumar

Reputation: 772

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);

Enpoint

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
    authSettings;

}

What is going wrong in my code?

Upvotes: 0

Views: 1081

Answers (1)

devkat
devkat

Reputation: 1644

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

onComplete(save) { appSettings =>
  complete("To insert app settings")
}

Upvotes: 1

Related Questions