Route concatenation operator should use value class and possibly be by name in its second argument

The route concatenation extension operator “~” is implemented by

  class RouteWithConcatenation(route: Route) {
     * 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 ⇒
      import ctx.executionContext
      route(ctx).fast.flatMap {
        case x: RouteResult.Complete ⇒ FastFuture.successful(x)
        case RouteResult.Rejected(outerRejections) ⇒
          other(ctx) {
            case x: RouteResult.Complete               ⇒ x
            case RouteResult.Rejected(innerRejections) ⇒ RouteResult.Rejected(outerRejections ++ innerRejections)

I think the class should extend AnyVal and the argument of the ~ method could be by name. There is an old Spray issue where @sirthias says that route evaluation in akka-http will be lazy (cf.

Sounds like it makes sense, would you be up for making a PR changing that?

will do…