2014-01-05 38 views
0

我试图用喷雾分离如下:如何使用scala spray detach?

path("") { 
    get { 
    detach { 
     respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here 
     complete { 
      <html> 
      <body> 
       <h1>Say hello to <i>spray-routing</i> on <i>Jetty</i>!</h1> 
      </body> 
      </html> 
     } 

     } 
    } 
    } 
} 

,但我得到以下编译错误:

type mismatch; found : spray.routing.RequestContext => Unit required: spray.routing.directives.DetachMagnet respondWithMediaType(text/html) { // XML is marshalled to text/xml by default, so we simply override here ^

我看了看:https://github.com/spray/spray/wiki/Detach,我仍然不知道我在做什么错...

回答

3

您正在查看已弃用的文档。如果您想阅读当前的文档,您必须查看spray.io网站。

关于您的问题,当前文档指定为detach指令不同的签名 - see here

def detach()(implicit ec: ExecutionContext): Directive0 
def detach()(implicit refFactory: ActorRefFactory): Directive0 
def detach(ec: ExecutionContext): Directive0 

当你正在通过你的ExecutionContext暗示我猜,你必须写在括号:

detach() { 
    respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here 
    complete { ...