I'm trying to nest existing akka http (version 10) directives to create my own custom directives. I'm having issues with things like this:
def echoHeaderDirective: Directive0 = optionalHeaderValueByName("X-Echo-Header") {
case Some(value) => respondWithHeader(RawHeader("X-Echo-Header", value))
case _ => pass
}
The type being returned from the match is Directive0
, but I get this error from IDEA
Expression of type Directive0 doesn't conform to expected type Route
and this error from the compiler
type mismatch;
[error] found : akka.http.scaladsl.server.Directive0
[error] (which expands to) akka.http.scaladsl.server.Directive[Unit]
[error] required: akka.http.scaladsl.server.RequestContext => scala.concurrent.Future[akka.http.scaladsl.server.RouteResult]
[error] case Some(value) => respondWithHeader(RawHeader("X-Echo-Header", value))
is it possible to create custom directives in this style (nesting), and if so, what am I doing wrong?