我是Scala和akka的新手,我正在尝试发布端点。编译后发生错误。
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 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定义
def persistAuthSettings(authSettings: AuthSettings) : Future[AuthSettings] = Future {
//Neo4j Operations
authSettings;
}
我的代码出了什么问题?
答案 0 :(得分:1)
onComplete
从未来提取值,并需要一个对此值进行操作的函数:
onComplete(save) { appSettings =>
complete("To insert app settings")
}