akka/akka-http

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

Open

#879 创建于 2017年2月20日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)Scala (1,311 star) (598 fork)batch import
1 - triagedhelp wantedt:routing

描述

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

贡献者指南

Provide Segments path directive that matches 0 to n segments regardless of leading slashes · akka/akka-http#879 | Good First Issue