我是新來的Scala,並試圖寫一點REST API。我正在使用Scala 11.2,Spray 1.3.1和akka 2.3.6。更正錯誤: - 必需:spray.httpx.marshalling.ToResponseMarshallable
我基本上試圖從噴霧中編寫一個例子。 我得到的每條路線的錯誤是: 類型不匹配;發現:String(「pong !!!!!!!!」)required:spray.httpx.marshalling.ToResponseMarshallable
我不確定它是版本不兼容問題還是缺少引用。
下面是從噴霧例如把我的路線定義:
package com.Shenandoah.SBIR.httpInterface
import spray.routing.HttpService
trait HttpInterface extends HttpService {
def pingRoute = path("ping") {
get { complete("pong!!!!!!!!") }
}
def pongRoute = path("pong") {
get { complete("pong!?") }
}
def pipRoute = path("pip") {
get { complete("moonshine") }
}
def rootRoute = pingRoute ~ pongRoute ~ pipRoute
}
Here is the actor:
package com.Shenandoah.SBIR.httpInterface
import akka.actor._
class HttpInterfaceActor extends HttpInterface with Actor {
// the HttpService trait defines
// only one abstract member, which connects the services environment
// to the enclosing actor or test.
def actorRefFactory = context
def receive = runRoute(rootRoute)
}