{"action":"created","comment":{"url":"https://api.github.com/repos/line/armeria/pulls/comments/89441551","pull_request_review_id":9985925,"id":89441551,"diff_hunk":"@@ -0,0 +1,126 @@\n+/*\n+ * Copyright 2016 LINE Corporation\n+ *\n+ * LINE Corporation licenses this file to you under the Apache License,\n+ * version 2.0 (the \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at:\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package com.linecorp.armeria.server.http.dynamic;\n+\n+import java.lang.annotation.Annotation;\n+import java.lang.reflect.Method;\n+import java.util.Arrays;\n+import java.util.EnumSet;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.stream.Collectors;\n+\n+import com.google.common.collect.ImmutableMap;\n+\n+import com.linecorp.armeria.common.http.HttpMethod;\n+\n+/**\n+ * Provides various utility functions for {@link Method} object.\n+ */\n+final class Methods {\n+\n+    /**\n+     * Mapping from HTTP method annotation to {@link HttpMethod}, like following.\n+     *\n+     * <ul>\n+     *   <li> {@link Options} -> {@link HttpMethod#OPTIONS}\n+     *   <li> {@link Get} -> {@link HttpMethod#GET}\n+     *   <li> {@link Head} -> {@link HttpMethod#HEAD}\n+     *   <li> {@link Post} -> {@link HttpMethod#POST}\n+     *   <li> {@link Put} -> {@link HttpMethod#PUT}\n+     *   <li> {@link Patch} -> {@link HttpMethod#PATCH}\n+     *   <li> {@link Delete} -> {@link HttpMethod#DELETE}\n+     *   <li> {@link Trace} -> {@link HttpMethod#TRACE}\n+     *   <li> {@link Connect} -> {@link HttpMethod#CONNECT}\n+     * </ul>\n+     */\n+    private static final Map<Class<?>, HttpMethod> HTTP_METHOD_MAP =\n+            ImmutableMap.<Class<?>, HttpMethod>builder()\n+                    .put(Options.class, HttpMethod.OPTIONS)\n+                    .put(Get.class, HttpMethod.GET)\n+                    .put(Head.class, HttpMethod.HEAD)\n+                    .put(Post.class, HttpMethod.POST)\n+                    .put(Put.class, HttpMethod.PUT)\n+                    .put(Patch.class, HttpMethod.PATCH)\n+                    .put(Delete.class, HttpMethod.DELETE)\n+                    .put(Trace.class, HttpMethod.TRACE)\n+                    .put(Connect.class, HttpMethod.CONNECT)\n+                    .build();\n+\n+    /**\n+     * Returns the array of {@link Path} annotated methods.\n+     */\n+    public static Method[] requestMappingMethods(Object object) {\n+        List<Method> methods = Arrays.stream(object.getClass().getMethods())\n+                                     .filter(m -> null != m.getAnnotation(Path.class))\n+                                     .collect(Collectors.toList());\n+        return methods.toArray(new Method[methods.size()]);\n+    }\n+\n+    /**\n+     * Returns the array of parameter types.\n+     */\n+    public static Class<?>[] parameterTypes(Method method) {\n+        int parameterCount = method.getParameterCount();\n+        return Arrays.stream(method.getParameters())\n+                     .map(p -> p.getType())\n+                     .toArray(size -> new Class<?>[parameterCount]);","path":"core/src/main/java/com/linecorp/armeria/server/http/dynamic/Methods.java","position":81,"original_position":81,"commit_id":"d1007ab8f0ac658deef19297961fdaad7700699c","original_commit_id":"d1007ab8f0ac658deef19297961fdaad7700699c","user":{"login":"trustin","id":173918,"avatar_url":"https://avatars.githubusercontent.com/u/173918?v=3","gravatar_id":"","url":"https://api.github.com/users/trustin","html_url":"https://github.com/trustin","followers_url":"https://api.github.com/users/trustin/followers","following_url":"https://api.github.com/users/trustin/following{/other_user}","gists_url":"https://api.github.com/users/trustin/gists{/gist_id}","starred_url":"https://api.github.com/users/trustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trustin/subscriptions","organizations_url":"https://api.github.com/users/trustin/orgs","repos_url":"https://api.github.com/users/trustin/repos","events_url":"https://api.github.com/users/trustin/events{/privacy}","received_events_url":"https://api.github.com/users/trustin/received_events","type":"User","site_admin":false},"body":"Does `Class[]::new` work here?","created_at":"2016-11-24T06:39:08Z","updated_at":"2016-11-24T06:41:35Z","html_url":"https://github.com/line/armeria/pull/321#discussion_r89441551","pull_request_url":"https://api.github.com/repos/line/armeria/pulls/321","_links":{"self":{"href":"https://api.github.com/repos/line/armeria/pulls/comments/89441551"},"html":{"href":"https://github.com/line/armeria/pull/321#discussion_r89441551"},"pull_request":{"href":"https://api.github.com/repos/line/armeria/pulls/321"}}},"pull_request":{"url":"https://api.github.com/repos/line/armeria/pulls/321","id":92112839,"html_url":"https://github.com/line/armeria/pull/321","diff_url":"https://github.com/line/armeria/pull/321.diff","patch_url":"https://github.com/line/armeria/pull/321.patch","issue_url":"https://api.github.com/repos/line/armeria/issues/321","number":321,"state":"open","locked":false,"title":"Implement advanced request mapping","user":{"login":"dongjinleekr","id":2375128,"avatar_url":"https://avatars.githubusercontent.com/u/2375128?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjinleekr","html_url":"https://github.com/dongjinleekr","followers_url":"https://api.github.com/users/dongjinleekr/followers","following_url":"https://api.github.com/users/dongjinleekr/following{/other_user}","gists_url":"https://api.github.com/users/dongjinleekr/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjinleekr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjinleekr/subscriptions","organizations_url":"https://api.github.com/users/dongjinleekr/orgs","repos_url":"https://api.github.com/users/dongjinleekr/repos","events_url":"https://api.github.com/users/dongjinleekr/events{/privacy}","received_events_url":"https://api.github.com/users/dongjinleekr/received_events","type":"User","site_admin":false},"body":"This pull request resolves #150","created_at":"2016-11-03T08:48:33Z","updated_at":"2016-11-24T06:41:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e3cb99f42292e28111d1f6faebfcaeecd8a1af42","assignee":{"login":"trustin","id":173918,"avatar_url":"https://avatars.githubusercontent.com/u/173918?v=3","gravatar_id":"","url":"https://api.github.com/users/trustin","html_url":"https://github.com/trustin","followers_url":"https://api.github.com/users/trustin/followers","following_url":"https://api.github.com/users/trustin/following{/other_user}","gists_url":"https://api.github.com/users/trustin/gists{/gist_id}","starred_url":"https://api.github.com/users/trustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trustin/subscriptions","organizations_url":"https://api.github.com/users/trustin/orgs","repos_url":"https://api.github.com/users/trustin/repos","events_url":"https://api.github.com/users/trustin/events{/privacy}","received_events_url":"https://api.github.com/users/trustin/received_events","type":"User","site_admin":false},"assignees":[{"login":"trustin","id":173918,"avatar_url":"https://avatars.githubusercontent.com/u/173918?v=3","gravatar_id":"","url":"https://api.github.com/users/trustin","html_url":"https://github.com/trustin","followers_url":"https://api.github.com/users/trustin/followers","following_url":"https://api.github.com/users/trustin/following{/other_user}","gists_url":"https://api.github.com/users/trustin/gists{/gist_id}","starred_url":"https://api.github.com/users/trustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trustin/subscriptions","organizations_url":"https://api.github.com/users/trustin/orgs","repos_url":"https://api.github.com/users/trustin/repos","events_url":"https://api.github.com/users/trustin/events{/privacy}","received_events_url":"https://api.github.com/users/trustin/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/line/armeria/pulls/321/commits","review_comments_url":"https://api.github.com/repos/line/armeria/pulls/321/comments","review_comment_url":"https://api.github.com/repos/line/armeria/pulls/comments{/number}","comments_url":"https://api.github.com/repos/line/armeria/issues/321/comments","statuses_url":"https://api.github.com/repos/line/armeria/statuses/d1007ab8f0ac658deef19297961fdaad7700699c","head":{"label":"dongjinleekr:feature/issue-150","ref":"feature/issue-150","sha":"d1007ab8f0ac658deef19297961fdaad7700699c","user":{"login":"dongjinleekr","id":2375128,"avatar_url":"https://avatars.githubusercontent.com/u/2375128?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjinleekr","html_url":"https://github.com/dongjinleekr","followers_url":"https://api.github.com/users/dongjinleekr/followers","following_url":"https://api.github.com/users/dongjinleekr/following{/other_user}","gists_url":"https://api.github.com/users/dongjinleekr/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjinleekr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjinleekr/subscriptions","organizations_url":"https://api.github.com/users/dongjinleekr/orgs","repos_url":"https://api.github.com/users/dongjinleekr/repos","events_url":"https://api.github.com/users/dongjinleekr/events{/privacy}","received_events_url":"https://api.github.com/users/dongjinleekr/received_events","type":"User","site_admin":false},"repo":{"id":62859657,"name":"armeria","full_name":"dongjinleekr/armeria","owner":{"login":"dongjinleekr","id":2375128,"avatar_url":"https://avatars.githubusercontent.com/u/2375128?v=3","gravatar_id":"","url":"https://api.github.com/users/dongjinleekr","html_url":"https://github.com/dongjinleekr","followers_url":"https://api.github.com/users/dongjinleekr/followers","following_url":"https://api.github.com/users/dongjinleekr/following{/other_user}","gists_url":"https://api.github.com/users/dongjinleekr/gists{/gist_id}","starred_url":"https://api.github.com/users/dongjinleekr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dongjinleekr/subscriptions","organizations_url":"https://api.github.com/users/dongjinleekr/orgs","repos_url":"https://api.github.com/users/dongjinleekr/repos","events_url":"https://api.github.com/users/dongjinleekr/events{/privacy}","received_events_url":"https://api.github.com/users/dongjinleekr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dongjinleekr/armeria","description":"Asynchronous RPC/API client/server library built on top of Java 8, Netty 4.1, HTTP/2, and Thrift","fork":true,"url":"https://api.github.com/repos/dongjinleekr/armeria","forks_url":"https://api.github.com/repos/dongjinleekr/armeria/forks","keys_url":"https://api.github.com/repos/dongjinleekr/armeria/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dongjinleekr/armeria/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dongjinleekr/armeria/teams","hooks_url":"https://api.github.com/repos/dongjinleekr/armeria/hooks","issue_events_url":"https://api.github.com/repos/dongjinleekr/armeria/issues/events{/number}","events_url":"https://api.github.com/repos/dongjinleekr/armeria/events","assignees_url":"https://api.github.com/repos/dongjinleekr/armeria/assignees{/user}","branches_url":"https://api.github.com/repos/dongjinleekr/armeria/branches{/branch}","tags_url":"https://api.github.com/repos/dongjinleekr/armeria/tags","blobs_url":"https://api.github.com/repos/dongjinleekr/armeria/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dongjinleekr/armeria/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dongjinleekr/armeria/git/refs{/sha}","trees_url":"https://api.github.com/repos/dongjinleekr/armeria/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dongjinleekr/armeria/statuses/{sha}","languages_url":"https://api.github.com/repos/dongjinleekr/armeria/languages","stargazers_url":"https://api.github.com/repos/dongjinleekr/armeria/stargazers","contributors_url":"https://api.github.com/repos/dongjinleekr/armeria/contributors","subscribers_url":"https://api.github.com/repos/dongjinleekr/armeria/subscribers","subscription_url":"https://api.github.com/repos/dongjinleekr/armeria/subscription","commits_url":"https://api.github.com/repos/dongjinleekr/armeria/commits{/sha}","git_commits_url":"https://api.github.com/repos/dongjinleekr/armeria/git/commits{/sha}","comments_url":"https://api.github.com/repos/dongjinleekr/armeria/comments{/number}","issue_comment_url":"https://api.github.com/repos/dongjinleekr/armeria/issues/comments{/number}","contents_url":"https://api.github.com/repos/dongjinleekr/armeria/contents/{+path}","compare_url":"https://api.github.com/repos/dongjinleekr/armeria/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dongjinleekr/armeria/merges","archive_url":"https://api.github.com/repos/dongjinleekr/armeria/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dongjinleekr/armeria/downloads","issues_url":"https://api.github.com/repos/dongjinleekr/armeria/issues{/number}","pulls_url":"https://api.github.com/repos/dongjinleekr/armeria/pulls{/number}","milestones_url":"https://api.github.com/repos/dongjinleekr/armeria/milestones{/number}","notifications_url":"https://api.github.com/repos/dongjinleekr/armeria/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dongjinleekr/armeria/labels{/name}","releases_url":"https://api.github.com/repos/dongjinleekr/armeria/releases{/id}","deployments_url":"https://api.github.com/repos/dongjinleekr/armeria/deployments","created_at":"2016-07-08T04:53:51Z","updated_at":"2016-07-08T04:53:53Z","pushed_at":"2016-11-24T05:24:22Z","git_url":"git://github.com/dongjinleekr/armeria.git","ssh_url":"git@github.com:dongjinleekr/armeria.git","clone_url":"https://github.com/dongjinleekr/armeria.git","svn_url":"https://github.com/dongjinleekr/armeria","homepage":"http://line.github.io/armeria/","size":13242,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"line:master","ref":"master","sha":"549eaffcb3f327f6e45501a208f7042c7c80f8a0","user":{"login":"line","id":13128444,"avatar_url":"https://avatars.githubusercontent.com/u/13128444?v=3","gravatar_id":"","url":"https://api.github.com/users/line","html_url":"https://github.com/line","followers_url":"https://api.github.com/users/line/followers","following_url":"https://api.github.com/users/line/following{/other_user}","gists_url":"https://api.github.com/users/line/gists{/gist_id}","starred_url":"https://api.github.com/users/line/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/line/subscriptions","organizations_url":"https://api.github.com/users/line/orgs","repos_url":"https://api.github.com/users/line/repos","events_url":"https://api.github.com/users/line/events{/privacy}","received_events_url":"https://api.github.com/users/line/received_events","type":"Organization","site_admin":false},"repo":{"id":46251204,"name":"armeria","full_name":"line/armeria","owner":{"login":"line","id":13128444,"avatar_url":"https://avatars.githubusercontent.com/u/13128444?v=3","gravatar_id":"","url":"https://api.github.com/users/line","html_url":"https://github.com/line","followers_url":"https://api.github.com/users/line/followers","following_url":"https://api.github.com/users/line/following{/other_user}","gists_url":"https://api.github.com/users/line/gists{/gist_id}","starred_url":"https://api.github.com/users/line/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/line/subscriptions","organizations_url":"https://api.github.com/users/line/orgs","repos_url":"https://api.github.com/users/line/repos","events_url":"https://api.github.com/users/line/events{/privacy}","received_events_url":"https://api.github.com/users/line/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/line/armeria","description":"Asynchronous RPC/API client/server library built on top of Java 8, Netty 4.1, HTTP/2, and Thrift","fork":false,"url":"https://api.github.com/repos/line/armeria","forks_url":"https://api.github.com/repos/line/armeria/forks","keys_url":"https://api.github.com/repos/line/armeria/keys{/key_id}","collaborators_url":"https://api.github.com/repos/line/armeria/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/line/armeria/teams","hooks_url":"https://api.github.com/repos/line/armeria/hooks","issue_events_url":"https://api.github.com/repos/line/armeria/issues/events{/number}","events_url":"https://api.github.com/repos/line/armeria/events","assignees_url":"https://api.github.com/repos/line/armeria/assignees{/user}","branches_url":"https://api.github.com/repos/line/armeria/branches{/branch}","tags_url":"https://api.github.com/repos/line/armeria/tags","blobs_url":"https://api.github.com/repos/line/armeria/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/line/armeria/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/line/armeria/git/refs{/sha}","trees_url":"https://api.github.com/repos/line/armeria/git/trees{/sha}","statuses_url":"https://api.github.com/repos/line/armeria/statuses/{sha}","languages_url":"https://api.github.com/repos/line/armeria/languages","stargazers_url":"https://api.github.com/repos/line/armeria/stargazers","contributors_url":"https://api.github.com/repos/line/armeria/contributors","subscribers_url":"https://api.github.com/repos/line/armeria/subscribers","subscription_url":"https://api.github.com/repos/line/armeria/subscription","commits_url":"https://api.github.com/repos/line/armeria/commits{/sha}","git_commits_url":"https://api.github.com/repos/line/armeria/git/commits{/sha}","comments_url":"https://api.github.com/repos/line/armeria/comments{/number}","issue_comment_url":"https://api.github.com/repos/line/armeria/issues/comments{/number}","contents_url":"https://api.github.com/repos/line/armeria/contents/{+path}","compare_url":"https://api.github.com/repos/line/armeria/compare/{base}...{head}","merges_url":"https://api.github.com/repos/line/armeria/merges","archive_url":"https://api.github.com/repos/line/armeria/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/line/armeria/downloads","issues_url":"https://api.github.com/repos/line/armeria/issues{/number}","pulls_url":"https://api.github.com/repos/line/armeria/pulls{/number}","milestones_url":"https://api.github.com/repos/line/armeria/milestones{/number}","notifications_url":"https://api.github.com/repos/line/armeria/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/line/armeria/labels{/name}","releases_url":"https://api.github.com/repos/line/armeria/releases{/id}","deployments_url":"https://api.github.com/repos/line/armeria/deployments","created_at":"2015-11-16T04:04:01Z","updated_at":"2016-11-24T05:03:54Z","pushed_at":"2016-11-24T05:53:07Z","git_url":"git://github.com/line/armeria.git","ssh_url":"git@github.com:line/armeria.git","clone_url":"https://github.com/line/armeria.git","svn_url":"https://github.com/line/armeria","homepage":"http://line.github.io/armeria/","size":15620,"stargazers_count":598,"watchers_count":598,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":153,"mirror_url":null,"open_issues_count":35,"forks":153,"open_issues":35,"watchers":598,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/line/armeria/pulls/321"},"html":{"href":"https://github.com/line/armeria/pull/321"},"issue":{"href":"https://api.github.com/repos/line/armeria/issues/321"},"comments":{"href":"https://api.github.com/repos/line/armeria/issues/321/comments"},"review_comments":{"href":"https://api.github.com/repos/line/armeria/pulls/321/comments"},"review_comment":{"href":"https://api.github.com/repos/line/armeria/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/line/armeria/pulls/321/commits"},"statuses":{"href":"https://api.github.com/repos/line/armeria/statuses/d1007ab8f0ac658deef19297961fdaad7700699c"}}}}
{"actor":{"display_login":"trustin"}}