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:
type mismatch; found : spray.routing.RequestContext => Unit required: spray.routing.directives.DetachMagnet respondWithMediaType(
text/html
) { // XML is marshalled totext/xml
by default, so we simply override here ^
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.
Regarding your problem, the current documentation specifies a different signature for the
detach
directive - see hereAs you are passing your ExecutionContext implicitly I guess, you have to write the parenthesis: