{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka-grpc/pulls/comments/203810366","pull_request_review_id":138776117,"id":203810366,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMzgxMDM2Ng==","diff_hunk":"@@ -0,0 +1,69 @@\n+/**\n+ * Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>\n+ */\n+\n+package akka.grpc.internal\n+\n+import java.util.Optional\n+import java.util.concurrent.CompletionStage\n+\n+import akka.annotation.InternalApi\n+import akka.dispatch.{ Dispatchers, ExecutionContexts }\n+import akka.http.scaladsl.model.{ HttpRequest, HttpResponse }\n+import akka.stream.Materializer\n+import play.api.inject.Injector\n+import play.api.mvc.Handler\n+import play.api.mvc.akkahttp.AkkaHttpHandler\n+import play.api.routing.Router\n+import play.api.routing.Router.Routes\n+import play.mvc.Http\n+\n+import scala.concurrent.Future\n+import scala.compat.java8.FutureConverters._\n+import scala.compat.java8.OptionConverters._\n+\n+/**\n+ * INTERNAL API\n+ */\n+@InternalApi private[akka] object PlayRouterHelper {\n+  def handlerFor(javaHandler: akka.japi.Function[akka.http.javadsl.model.HttpRequest, CompletionStage[akka.http.javadsl.model.HttpResponse]]): HttpRequest => Future[HttpResponse] = AkkaHttpHandler.apply(req =>\n+    javaHandler.apply(req.asInstanceOf[akka.http.javadsl.model.HttpRequest])\n+      .toScala\n+      .map(javaResp => javaResp.asInstanceOf[akka.http.scaladsl.model.HttpResponse])(ExecutionContexts.sameThreadExecutionContext))\n+}\n+\n+/**\n+ * Boiler plate needed for the generated Play routers allowing for adding a service implementation in a Play app,\n+ * inherited by the generated abstract service router (both Java and Scala) which is then implemented by the user.\n+ *\n+ * INTERNAL API\n+ */\n+@InternalApi abstract class PlayRouter(mat: Materializer, serviceName: String) extends play.api.routing.Router {\n+\n+  /**\n+   * INTERNAL API\n+   */\n+  @InternalApi\n+  protected def createHandler(serviceName: String, mat: Materializer): HttpRequest => Future[HttpResponse]\n+\n+  private val handler = new AkkaHttpHandler {\n+    val handler = createHandler(serviceName, mat)\n+    override def apply(request: HttpRequest): Future[HttpResponse] = handler(request)\n+  }\n+\n+  // Scala API\n+  final override def routes: Routes = {\n+    case rh if rh.path.startsWith(serviceName) ⇒ handler\n+  }\n+\n+  final override def documentation: Seq[(String, String, String)] = Seq.empty\n+\n+  /**\n+   * Registering a gRPC service under a custom prefix is not widely supported and strongly discouraged by the specification\n+   * so therefore not supported.\n+   */\n+  final override def withPrefix(prefix: String): Router =\n+    throw new UnsupportedOperationException(\"Prefixing gRPC services is not widely supported, \" +\n+      \"strongly discouraged by the specification and therefore not supported\")","path":"runtime/src/main/scala/akka/grpc/internal/PlayRouter.scala","position":67,"original_position":67,"commit_id":"62eeaa7a68ad37b3e9b15474d1848b2b2d68bd10","original_commit_id":"62eeaa7a68ad37b3e9b15474d1848b2b2d68bd10","user":{"login":"johanandren","id":666915,"node_id":"MDQ6VXNlcjY2NjkxNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/666915?v=4","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"body":"You are perfectly right, how else would it work. 🤦‍♂️ ","created_at":"2018-07-19T17:30:46Z","updated_at":"2018-07-19T17:30:46Z","html_url":"https://github.com/akka/akka-grpc/pull/291#discussion_r203810366","pull_request_url":"https://api.github.com/repos/akka/akka-grpc/pulls/291","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/akka/akka-grpc/pulls/comments/203810366"},"html":{"href":"https://github.com/akka/akka-grpc/pull/291#discussion_r203810366"},"pull_request":{"href":"https://api.github.com/repos/akka/akka-grpc/pulls/291"}},"in_reply_to_id":203770839},"pull_request":{"url":"https://api.github.com/repos/akka/akka-grpc/pulls/291","id":200998414,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwOTk4NDE0","html_url":"https://github.com/akka/akka-grpc/pull/291","diff_url":"https://github.com/akka/akka-grpc/pull/291.diff","patch_url":"https://github.com/akka/akka-grpc/pull/291.patch","issue_url":"https://api.github.com/repos/akka/akka-grpc/issues/291","number":291,"state":"open","locked":false,"title":"Simpler server usage in Play","user":{"login":"johanandren","id":666915,"node_id":"MDQ6VXNlcjY2NjkxNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/666915?v=4","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"body":"This allows for just one class, annotated as Singleton (or injected in some other way - no longer tied to Guice) referenced in the routes file like so:\r\n\r\n```\r\n@Singleton \r\nclass MyWhateverNameILike @Inject() (i: Injector) extends AbstractGreeterServiceRouter(i) {\r\n ... gRPC method implementations ...\r\n} \r\n\r\nin the routes file\r\n->     /helloworld.GreeterService   whatever.package.MyWhateverNameILike\r\n```\r\n\r\nOriginally conceived here: https://github.com/raboof/play-scala-grpc-server/pull/8/files","created_at":"2018-07-12T13:18:40Z","updated_at":"2018-07-19T17:30:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9b94c0da2dae5fdaf25ad35fe6ad3df61e45144","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka-grpc/pulls/291/commits","review_comments_url":"https://api.github.com/repos/akka/akka-grpc/pulls/291/comments","review_comment_url":"https://api.github.com/repos/akka/akka-grpc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka-grpc/issues/291/comments","statuses_url":"https://api.github.com/repos/akka/akka-grpc/statuses/62eeaa7a68ad37b3e9b15474d1848b2b2d68bd10","head":{"label":"johanandren:play-router-no-fuzz-johanandren","ref":"play-router-no-fuzz-johanandren","sha":"62eeaa7a68ad37b3e9b15474d1848b2b2d68bd10","user":{"login":"johanandren","id":666915,"node_id":"MDQ6VXNlcjY2NjkxNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/666915?v=4","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"repo":{"id":128755440,"node_id":"MDEwOlJlcG9zaXRvcnkxMjg3NTU0NDA=","name":"akka-grpc","full_name":"johanandren/akka-grpc","owner":{"login":"johanandren","id":666915,"node_id":"MDQ6VXNlcjY2NjkxNQ==","avatar_url":"https://avatars3.githubusercontent.com/u/666915?v=4","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johanandren/akka-grpc","description":"Akka gRPC","fork":true,"url":"https://api.github.com/repos/johanandren/akka-grpc","forks_url":"https://api.github.com/repos/johanandren/akka-grpc/forks","keys_url":"https://api.github.com/repos/johanandren/akka-grpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johanandren/akka-grpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johanandren/akka-grpc/teams","hooks_url":"https://api.github.com/repos/johanandren/akka-grpc/hooks","issue_events_url":"https://api.github.com/repos/johanandren/akka-grpc/issues/events{/number}","events_url":"https://api.github.com/repos/johanandren/akka-grpc/events","assignees_url":"https://api.github.com/repos/johanandren/akka-grpc/assignees{/user}","branches_url":"https://api.github.com/repos/johanandren/akka-grpc/branches{/branch}","tags_url":"https://api.github.com/repos/johanandren/akka-grpc/tags","blobs_url":"https://api.github.com/repos/johanandren/akka-grpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johanandren/akka-grpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johanandren/akka-grpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/johanandren/akka-grpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johanandren/akka-grpc/statuses/{sha}","languages_url":"https://api.github.com/repos/johanandren/akka-grpc/languages","stargazers_url":"https://api.github.com/repos/johanandren/akka-grpc/stargazers","contributors_url":"https://api.github.com/repos/johanandren/akka-grpc/contributors","subscribers_url":"https://api.github.com/repos/johanandren/akka-grpc/subscribers","subscription_url":"https://api.github.com/repos/johanandren/akka-grpc/subscription","commits_url":"https://api.github.com/repos/johanandren/akka-grpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/johanandren/akka-grpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/johanandren/akka-grpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/johanandren/akka-grpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/johanandren/akka-grpc/contents/{+path}","compare_url":"https://api.github.com/repos/johanandren/akka-grpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johanandren/akka-grpc/merges","archive_url":"https://api.github.com/repos/johanandren/akka-grpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johanandren/akka-grpc/downloads","issues_url":"https://api.github.com/repos/johanandren/akka-grpc/issues{/number}","pulls_url":"https://api.github.com/repos/johanandren/akka-grpc/pulls{/number}","milestones_url":"https://api.github.com/repos/johanandren/akka-grpc/milestones{/number}","notifications_url":"https://api.github.com/repos/johanandren/akka-grpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johanandren/akka-grpc/labels{/name}","releases_url":"https://api.github.com/repos/johanandren/akka-grpc/releases{/id}","deployments_url":"https://api.github.com/repos/johanandren/akka-grpc/deployments","created_at":"2018-04-09T10:35:16Z","updated_at":"2018-06-20T12:45:09Z","pushed_at":"2018-07-19T13:18:50Z","git_url":"git://github.com/johanandren/akka-grpc.git","ssh_url":"git@github.com:johanandren/akka-grpc.git","clone_url":"https://github.com/johanandren/akka-grpc.git","svn_url":"https://github.com/johanandren/akka-grpc","homepage":"https://akka.io","size":895,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"akka:master","ref":"master","sha":"17af187c6bae13678997e753997d147964482c94","user":{"login":"akka","id":1496237,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0OTYyMzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1496237?v=4","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":120786720,"node_id":"MDEwOlJlcG9zaXRvcnkxMjA3ODY3MjA=","name":"akka-grpc","full_name":"akka/akka-grpc","owner":{"login":"akka","id":1496237,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0OTYyMzc=","avatar_url":"https://avatars2.githubusercontent.com/u/1496237?v=4","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-grpc","description":"Akka gRPC","fork":false,"url":"https://api.github.com/repos/akka/akka-grpc","forks_url":"https://api.github.com/repos/akka/akka-grpc/forks","keys_url":"https://api.github.com/repos/akka/akka-grpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka-grpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka-grpc/teams","hooks_url":"https://api.github.com/repos/akka/akka-grpc/hooks","issue_events_url":"https://api.github.com/repos/akka/akka-grpc/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka-grpc/events","assignees_url":"https://api.github.com/repos/akka/akka-grpc/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka-grpc/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka-grpc/tags","blobs_url":"https://api.github.com/repos/akka/akka-grpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka-grpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka-grpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka-grpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka-grpc/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka-grpc/languages","stargazers_url":"https://api.github.com/repos/akka/akka-grpc/stargazers","contributors_url":"https://api.github.com/repos/akka/akka-grpc/contributors","subscribers_url":"https://api.github.com/repos/akka/akka-grpc/subscribers","subscription_url":"https://api.github.com/repos/akka/akka-grpc/subscription","commits_url":"https://api.github.com/repos/akka/akka-grpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka-grpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka-grpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka-grpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka-grpc/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka-grpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka-grpc/merges","archive_url":"https://api.github.com/repos/akka/akka-grpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka-grpc/downloads","issues_url":"https://api.github.com/repos/akka/akka-grpc/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka-grpc/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka-grpc/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka-grpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka-grpc/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka-grpc/releases{/id}","deployments_url":"https://api.github.com/repos/akka/akka-grpc/deployments","created_at":"2018-02-08T16:28:56Z","updated_at":"2018-07-19T12:01:10Z","pushed_at":"2018-07-19T16:20:52Z","git_url":"git://github.com/akka/akka-grpc.git","ssh_url":"git@github.com:akka/akka-grpc.git","clone_url":"https://github.com/akka/akka-grpc.git","svn_url":"https://github.com/akka/akka-grpc","homepage":"https://developer.lightbend.com/docs/akka-grpc/current/","size":893,"stargazers_count":117,"watchers_count":117,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11,"mirror_url":null,"archived":false,"open_issues_count":57,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":11,"open_issues":57,"watchers":117,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka-grpc/pulls/291"},"html":{"href":"https://github.com/akka/akka-grpc/pull/291"},"issue":{"href":"https://api.github.com/repos/akka/akka-grpc/issues/291"},"comments":{"href":"https://api.github.com/repos/akka/akka-grpc/issues/291/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka-grpc/pulls/291/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka-grpc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka-grpc/pulls/291/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka-grpc/statuses/62eeaa7a68ad37b3e9b15474d1848b2b2d68bd10"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"johanandren"}}