akka/akka-http

Provide Segments path directive that matches 0 to n segments regardless of leading slashes

オープン

#879 opened on 2017/02/20

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)Scala (598 件のフォーク)batch import
1 - triagedhelp wantedt:routing

Repository metrics

Stars
 (1,311 個のスター)
PR merge metrics
 (平均マージ 1d 10h) (30d で 2 merged PRs)

説明

The existing Segments PathMatcher is mostly useful when trailing slashes are enforced everywhere. When no trailing slashes it is a bit more complicated right now to get a list of segments.

The implementation can be basically this:

def pathSegments: Directive1[List[String]] = (Slash ~ Segment).repeat(0, 128, PathMatchers.Neutral) ~ PathEnd // or PathEndOrSingleSlash?

It would allow to use

pathPrefix("tree") {
  pathSegments { segments =>
    ...
  }
}

which would match all of

  • /tree
  • /tree/abc
  • /tree/abc/def

but not

  • /tree/
  • /tree/abc/

/cc @lihaoyi

コントリビューターガイド