1
我正在閱讀akka-http源代碼,這裏是akka.http.scaladsl.server.directives.RouteDirectives
的源代碼,以complete
方法爲例,任何人都可以告訴StandardRoute(_.complete(m))
下劃線的含義是什麼?這個下劃線的含義是什麼?
package akka.http.scaladsl.server
package directives
import akka.http.scaladsl.marshalling.ToResponseMarshallable
import akka.http.scaladsl.model._
import StatusCodes._
/**
* @groupname route Route directives
* @groupprio route 200
*/
trait RouteDirectives {
....
....
/**
* Completes the request using the given arguments.
*
* @group route
*/
def complete(m: ⇒ ToResponseMarshallable): StandardRoute =
StandardRoute(_.complete(m))
}
object RouteDirectives extends RouteDirectives {
private val _reject = StandardRoute(_.reject())
}
不,StandardRoute的適用方法只接受路由實例。 –
@LaurenceGeng路線必須擴展功能 – pamu
@LaurenceGeng'StandardRoute(_。complete(m))'可以用'StandardRoute(x => x.complete(m))替換' – pamu