如何尽可能地折叠这些指令?
我能够将三个指令折叠到 mainHeader 中,但是如何也包括 authenticate 和 responseWithMediaType 呢?
val mainHeaders = cors & headerValueByName("Access_Token") & headerValueByName("Tenant_Name")
override def getLayer = path("api" / Segment / "model" / "layers") { modeledSystemName =>
mainHeaders { (accessToken, tenantName) =>
authenticate(validate(accessToken)) { authInfo =>
respondWithMediaType(`application/json`) {
get {
onComplete(service.getlayers(modeledSystemName, tenantName)) {
case Success(layers) => complete(layers)
//case Success(None) => complete(NotFound, "Release version not found")
case Failure(ex) => complete(InternalServerError, s"An error occurred: ${ex.getMessage}")
}
}
}
}
}
}