{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/52924141","id":52924141,"diff_hunk":"@@ -1,112 +1,42 @@\n /*\n  * Copyright (C) 2009-2016 Typesafe Inc. <http://www.typesafe.com>\n  */\n+package akka.http.javadsl.server.directives\n \n-package akka.http.javadsl.server\n-package directives\n-\n-import akka.http.impl.server.RouteStructure\n-import akka.http.impl.server.RouteStructure.{ RedirectToNoTrailingSlashIfPresent, RedirectToTrailingSlashIfMissing }\n+import akka.http.scaladsl.server.PathMatchers\n+import java.util.function.Supplier\n+import java.util.function.{ Function ⇒ JFunction }\n+import akka.http.javadsl.server.Route\n+import akka.http.scaladsl.server.PathMatcher.segmentStringToPathMatcher\n+import akka.http.scaladsl.server.{ Directives ⇒ D }\n+import akka.http.javadsl.server.Unmarshaller\n+import scala.util.Success\n+import scala.util.Failure\n+import akka.http.scaladsl.server.ValidationRejection\n+import akka.http.javadsl.server.PathMatcher0\n+import akka.http.javadsl.server.PathMatcher1\n+import akka.http.javadsl.server.PathMatcher2\n+import java.util.function.BiFunction\n+import akka.http.scaladsl.server.Directive0\n import akka.http.javadsl.model.StatusCode\n-import akka.http.javadsl.server.values.{ PathMatchers, PathMatcher }\n-\n-import scala.annotation.varargs\n-import scala.collection.immutable\n-\n-abstract class PathDirectives extends MiscDirectives {\n-  /**\n-   * Applies the given PathMatchers to the remaining unmatched path after consuming a leading slash.\n-   * The matcher has to match the remaining path completely.\n-   * If matched the value extracted by the PathMatchers is extracted on the directive level.\n-   *\n-   * Each of Each of the arguments s must either be an instance of [[PathMatcher]] or a constant String\n-   * that will be automatically converted using `PathMatcher.segment`.\n-   */\n-  @varargs\n-  def path(matchers: AnyRef*): Directive =\n-    RawPathPrefixForMatchers(joinWithSlash(convertMatchers(matchers)) :+ PathMatchers.END)\n-\n-  /**\n-   * Applies the given PathMatchers to a prefix of the remaining unmatched path after consuming a leading slash.\n-   * The matcher has to match a prefix of the remaining path.\n-   * If matched the value extracted by the PathMatcher is extracted on the directive level.\n-   *\n-   * Each of the arguments  must either be an instance of [[PathMatcher]] or a constant String\n-   * that will be automatically converted using `PathMatcher.segment`.\n-   */\n-  @varargs\n-  def pathPrefix(matchers: AnyRef*): Directive =\n-    RawPathPrefixForMatchers(joinWithSlash(convertMatchers(matchers)))\n-\n-  /**\n-   * Checks whether the unmatchedPath of the [[RequestContext]] has a prefix matched by the\n-   * given PathMatcher. In analogy to the `pathPrefix` directive a leading slash is implied.\n-   *\n-   * Each of the arguments  must either be an instance of [[PathMatcher]] or a constant String\n-   * that will be automatically converted using `PathMatcher.segment`.\n-   */\n-  @varargs\n-  def pathPrefixTest(matchers: AnyRef*): Directive =\n-    RawPathPrefixTestForMatchers(joinWithSlash(convertMatchers(matchers)))\n-\n-  /**\n-   * Applies the given matcher directly to a prefix of the unmatched path of the\n-   * [[RequestContext]] (i.e. without implicitly consuming a leading slash).\n-   * The matcher has to match a prefix of the remaining path.\n-   * If matched the value extracted by the PathMatcher is extracted on the directive level.\n-   *\n-   * Each of the arguments  must either be an instance of [[PathMatcher]] or a constant String\n-   * that will be automatically converted using `PathMatcher.segment`.\n-   */\n-  @varargs\n-  def rawPathPrefix(matchers: AnyRef*): Directive =\n-    RawPathPrefixForMatchers(convertMatchers(matchers))\n-\n-  /**\n-   * Checks whether the unmatchedPath of the [[RequestContext]] has a prefix matched by the\n-   * given PathMatcher. However, as opposed to the `pathPrefix` directive the matched path is not\n-   * actually \"consumed\".\n-   *\n-   * Each of the arguments  must either be an instance of [[PathMatcher]] or a constant String\n-   * that will be automatically converted using `PathMatcher.segment`.\n-   */\n-  @varargs\n-  def rawPathPrefixTest(matchers: AnyRef*): Directive =\n-    RawPathPrefixTestForMatchers(convertMatchers(matchers))\n+import akka.http.scaladsl.model.StatusCodes.Redirection\n \n-  /**\n-   * Applies the given PathMatchers to a suffix of the remaining unmatchedPath of the [[RequestContext]].\n-   * If matched the value extracted by the PathMatchers is extracted and the matched parts of the path are consumed.\n-   * Note that, for efficiency reasons, the given PathMatchers must match the desired suffix in reversed-segment\n-   * order, i.e. `pathSuffix(\"baz\" / \"bar\")` would match `/foo/bar/baz`!\n-   *\n-   * Each of the arguments  must either be an instance of [[PathMatcher]] or a constant String\n-   * that will be automatically converted using `PathMatcher.segment`.\n-   */\n-  @varargs\n-  def pathSuffix(matchers: AnyRef*): Directive =\n-    Directives.custom(RouteStructure.PathSuffix(convertMatchers(matchers)))\n-\n-  /**\n-   * Checks whether the unmatchedPath of the [[RequestContext]] has a suffix matched by the\n-   * given PathMatcher. However, as opposed to the pathSuffix directive the matched path is not\n-   * actually \"consumed\".\n-   * Note that, for efficiency reasons, the given PathMatcher must match the desired suffix in reversed-segment\n-   * order, i.e. `pathSuffixTest(\"baz\" / \"bar\")` would match `/foo/bar/baz`!\n-   *\n-   * Each of the arguments  must either be an instance of [[PathMatcher]] or a constant String\n-   * that will be automatically converted using `PathMatcher.segment`.\n-   */\n-  @varargs\n-  def pathSuffixTest(matchers: AnyRef*): Directive =\n-    Directives.custom(RouteStructure.PathSuffixTest(convertMatchers(matchers)))\n+/**\n+ * Only path prefixes are matched by these methods, since any kind of chaining path extractions\n+ * in Java would just look cumbersome without operator overloads; hence, no PathMatcher for Java.\n+ *\n+ * Just nest path() directives with the required types, ending in pathEnd() if you want to fail\n+ * further paths.\n+ */\n+abstract class PathDirectives extends ParameterDirectives {","path":"akka-http/src/main/scala/akka/http/javadsl/server/directives/PathDirectives.scala","position":127,"original_position":127,"commit_id":"12035cc5c2932c63b86a3e70001323500659498a","original_commit_id":"12035cc5c2932c63b86a3e70001323500659498a","user":{"login":"vasseurjb","id":1029919,"avatar_url":"https://avatars.githubusercontent.com/u/1029919?v=3","gravatar_id":"","url":"https://api.github.com/users/vasseurjb","html_url":"https://github.com/vasseurjb","followers_url":"https://api.github.com/users/vasseurjb/followers","following_url":"https://api.github.com/users/vasseurjb/following{/other_user}","gists_url":"https://api.github.com/users/vasseurjb/gists{/gist_id}","starred_url":"https://api.github.com/users/vasseurjb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vasseurjb/subscriptions","organizations_url":"https://api.github.com/users/vasseurjb/orgs","repos_url":"https://api.github.com/users/vasseurjb/repos","events_url":"https://api.github.com/users/vasseurjb/events{/privacy}","received_events_url":"https://api.github.com/users/vasseurjb/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/versioned/images/favicon.png) Issue found: [Number of methods in class exceeds 30](https://www.codacy.com/app/vasseurjb/akka/file/2046270054/issues/source?bid=3132306&fileBranchId=3132379#l31)","created_at":"2016-02-15T17:17:55Z","updated_at":"2016-02-15T17:17:55Z","html_url":"https://github.com/akka/akka/pull/19632#discussion_r52924141","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/19632","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/52924141"},"html":{"href":"https://github.com/akka/akka/pull/19632#discussion_r52924141"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/19632"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/19632","id":57372433,"html_url":"https://github.com/akka/akka/pull/19632","diff_url":"https://github.com/akka/akka/pull/19632.diff","patch_url":"https://github.com/akka/akka/pull/19632.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/19632","number":19632,"state":"open","locked":false,"title":"WIP #18919 Align Java HTTP server DSL with Scala","user":{"login":"jypma","id":483519,"avatar_url":"https://avatars.githubusercontent.com/u/483519?v=3","gravatar_id":"","url":"https://api.github.com/users/jypma","html_url":"https://github.com/jypma","followers_url":"https://api.github.com/users/jypma/followers","following_url":"https://api.github.com/users/jypma/following{/other_user}","gists_url":"https://api.github.com/users/jypma/gists{/gist_id}","starred_url":"https://api.github.com/users/jypma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jypma/subscriptions","organizations_url":"https://api.github.com/users/jypma/orgs","repos_url":"https://api.github.com/users/jypma/repos","events_url":"https://api.github.com/users/jypma/events{/privacy}","received_events_url":"https://api.github.com/users/jypma/received_events","type":"User","site_admin":false},"body":"This replaces the Java HTTP server DSL with a Java-8 centric one which exposes all scala DSL concepts to be usable from Java, including custom directives, (un)marshallers, rejections, headers, and type safety for path and query parameters. \r\n\r\nImplemented according to the direction agreed upon with @ktoso in https://github.com/akka/akka/issues/18919 . The class `JavaRouteTest` demoes the Java DSL's capabilities, and runs successfully currently (if you move the other test code out of the way).\r\n\r\nList of things to be done (somewhat in order):\r\n- [X] Migrated extra directives: `FileAndResourceDirectives`, `CodingDirectives`,`CookieDirectives`,`MiscDirectives`,  `HostDirectives`, `SchemeDirectives`\r\n- [X] Migrate the existing tests in `akka-http-tests` once the DSL direction is agreed \r\n- [ ] _(in progress)_ Fix compile errors in `akka-docs`\r\n- [ ] Fill in the missing directives that haven't been migrated yet (they're currently commented out): `CacheConditionDirectives`,  `RangeDirectives`,  `WebSocketDirectives`\r\n- [ ] Discuss how to resolve the introduced `TODO` and `FIXME` markers\r\n- [ ] Discuss whether to replace the current Java `RouteTestKit` (which has its own implementation different from the scala `RouteTestKit`) with a [wrapper](https://github.com/jypma/scala-japi/blob/master/akkaStreamsTest/src/main/scala/com/tradeshift/scalajapi/akka/route/RouteTestKit.scala) that delegates and re-uses the scala one.\r\n- [ ] Update textual documentation in `akka-docs`\r\n- [x] MUST: Add `FormFieldDirectives`\r\n- [x] MUST: Add `SecurityDirectives`, possibly Java-model a bit of the related classesupon\r\n- [ ] COULD: Add `DebuggingDirectives`, `FileUploadDirectives`, `RespondWithDirectives`\r\n","created_at":"2016-01-27T15:09:38Z","updated_at":"2016-02-15T17:17:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ab1eb52d1f9a9c279516c6f6e5b4f29e8d61d51","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/19632/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/19632/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/19632/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/12035cc5c2932c63b86a3e70001323500659498a","head":{"label":"jypma:java-http-server-dsl","ref":"java-http-server-dsl","sha":"12035cc5c2932c63b86a3e70001323500659498a","user":{"login":"jypma","id":483519,"avatar_url":"https://avatars.githubusercontent.com/u/483519?v=3","gravatar_id":"","url":"https://api.github.com/users/jypma","html_url":"https://github.com/jypma","followers_url":"https://api.github.com/users/jypma/followers","following_url":"https://api.github.com/users/jypma/following{/other_user}","gists_url":"https://api.github.com/users/jypma/gists{/gist_id}","starred_url":"https://api.github.com/users/jypma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jypma/subscriptions","organizations_url":"https://api.github.com/users/jypma/orgs","repos_url":"https://api.github.com/users/jypma/repos","events_url":"https://api.github.com/users/jypma/events{/privacy}","received_events_url":"https://api.github.com/users/jypma/received_events","type":"User","site_admin":false},"repo":{"id":5583654,"name":"akka","full_name":"jypma/akka","owner":{"login":"jypma","id":483519,"avatar_url":"https://avatars.githubusercontent.com/u/483519?v=3","gravatar_id":"","url":"https://api.github.com/users/jypma","html_url":"https://github.com/jypma","followers_url":"https://api.github.com/users/jypma/followers","following_url":"https://api.github.com/users/jypma/following{/other_user}","gists_url":"https://api.github.com/users/jypma/gists{/gist_id}","starred_url":"https://api.github.com/users/jypma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jypma/subscriptions","organizations_url":"https://api.github.com/users/jypma/orgs","repos_url":"https://api.github.com/users/jypma/repos","events_url":"https://api.github.com/users/jypma/events{/privacy}","received_events_url":"https://api.github.com/users/jypma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jypma/akka","description":"Akka Project","fork":true,"url":"https://api.github.com/repos/jypma/akka","forks_url":"https://api.github.com/repos/jypma/akka/forks","keys_url":"https://api.github.com/repos/jypma/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jypma/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jypma/akka/teams","hooks_url":"https://api.github.com/repos/jypma/akka/hooks","issue_events_url":"https://api.github.com/repos/jypma/akka/issues/events{/number}","events_url":"https://api.github.com/repos/jypma/akka/events","assignees_url":"https://api.github.com/repos/jypma/akka/assignees{/user}","branches_url":"https://api.github.com/repos/jypma/akka/branches{/branch}","tags_url":"https://api.github.com/repos/jypma/akka/tags","blobs_url":"https://api.github.com/repos/jypma/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jypma/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jypma/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/jypma/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jypma/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/jypma/akka/languages","stargazers_url":"https://api.github.com/repos/jypma/akka/stargazers","contributors_url":"https://api.github.com/repos/jypma/akka/contributors","subscribers_url":"https://api.github.com/repos/jypma/akka/subscribers","subscription_url":"https://api.github.com/repos/jypma/akka/subscription","commits_url":"https://api.github.com/repos/jypma/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/jypma/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/jypma/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/jypma/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/jypma/akka/contents/{+path}","compare_url":"https://api.github.com/repos/jypma/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jypma/akka/merges","archive_url":"https://api.github.com/repos/jypma/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jypma/akka/downloads","issues_url":"https://api.github.com/repos/jypma/akka/issues{/number}","pulls_url":"https://api.github.com/repos/jypma/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/jypma/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/jypma/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jypma/akka/labels{/name}","releases_url":"https://api.github.com/repos/jypma/akka/releases{/id}","deployments_url":"https://api.github.com/repos/jypma/akka/deployments","created_at":"2012-08-28T09:28:44Z","updated_at":"2013-01-12T00:06:30Z","pushed_at":"2016-02-11T14:05:23Z","git_url":"git://github.com/jypma/akka.git","ssh_url":"git@github.com:jypma/akka.git","clone_url":"https://github.com/jypma/akka.git","svn_url":"https://github.com/jypma/akka","homepage":"http://akka.io","size":171195,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"akka:master","ref":"master","sha":"af95476d1ef9f579e9c8934ac3753b98dff83541","user":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"name":"akka","full_name":"akka/akka","owner":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akka/akka","description":"Akka Project","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","deployments_url":"https://api.github.com/repos/akka/akka/deployments","created_at":"2009-02-16T12:51:54Z","updated_at":"2016-02-15T15:37:07Z","pushed_at":"2016-02-15T16:39:02Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":184155,"stargazers_count":5098,"watchers_count":5098,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1565,"mirror_url":null,"open_issues_count":863,"forks":1565,"open_issues":863,"watchers":5098,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/19632"},"html":{"href":"https://github.com/akka/akka/pull/19632"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/19632"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/19632/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/19632/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/19632/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/12035cc5c2932c63b86a3e70001323500659498a"}}}}