本文介绍了如何使用scala喷雾分离器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用喷雾分离器,如下所示:
i'm trying to use spray detach as following:
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>
}
}
}
}
}
,但出现以下编译错误:
but i get following compilation error:
我查看了:,我仍然不知道我在做什么错...
I looked at: https://github.com/spray/spray/wiki/Detach and I still have no idea what i'm doing wrong...
推荐答案
不推荐使用的文档。如果要阅读当前文档,则必须查看网站。
You are looking at a deprecated documentation. If you to want to read the current documentation you have to look at the spray.io website.
关于您的问题,当前文档为 detach
指令指定了不同的签名-
Regarding your problem, the current documentation specifies a different signature for the detach
directive - see here
def detach()(implicit ec: ExecutionContext): Directive0
def detach()(implicit refFactory: ActorRefFactory): Directive0
def detach(ec: ExecutionContext): Directive0
当我隐式传递ExecutionContext时,您必须写上括号:
As you are passing your ExecutionContext implicitly I guess, you have to write the parenthesis:
detach() {
respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here
complete { ...
这篇关于如何使用scala喷雾分离器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!