pekko/akka-http/src/main/scala/akka/http/server/StandardRoute.scala

27 lines
No EOL
813 B
Scala

/*
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.http.server
import akka.http.server.util.Tuple
/**
* A Route that can be implicitly converted into a Directive (fitting any signature).
*/
abstract class StandardRoute extends Route {
def toDirective[L: Tuple]: Directive[L] = StandardRoute.toDirective(this)
}
object StandardRoute {
def apply(route: Route): StandardRoute = route match {
case x: StandardRoute x
case x new StandardRoute { def apply(ctx: RequestContext) = x(ctx) }
}
/**
* Converts the StandardRoute into a directive that never passes the request to its inner route
* (and always returns its underlying route).
*/
implicit def toDirective[L: Tuple](route: StandardRoute) = Directive[L] { _ route }
}