2017-08-14 63 views

回答

1

我假設你指的是~方法對噴射/阿卡-HTTP。它所做的是鏈上的兩個路由一起:

/** 
* Returns a Route that chains two Routes. If the first Route rejects the request the second route is given a 
* chance to act upon the request. 
*/ 
def ~(other: Route): Route = { ctx ⇒ 
    route { 
    ctx.withRejectionHandling { rejections ⇒ 
     other(ctx.withRejectionsMapped(rejections ++ _)) 
    } 
    } 

噴霧,一個Route是一個函數取一個RequestContext和返回Unit一個類型別名:

type Route = RequestContext ⇒ Unit 

而且在阿卡-HTTP,它返回Future[RouteResult]

type Route = RequestContext => Future[RouteResult]