{"action":"created","comment":{"url":"https://api.github.com/repos/imbrobits/loosh/pulls/comments/79290139","id":79290139,"diff_hunk":"@@ -0,0 +1,114 @@\n+/*\n+ * MIT License\n+ *\n+ * Copyright (c) 2016 Nhan Nguyen\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in all\n+ * copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ * SOFTWARE.\n+ */\n+\n+package imbrobits.loosh.core;\n+\n+import com.google.inject.Guice;\n+import com.google.inject.Inject;\n+import com.google.inject.Injector;\n+import imbrobits.loosh.core.annotations.Controller;\n+import imbrobits.loosh.handler.IOAuth2Handler;\n+import io.vertx.core.Handler;\n+import io.vertx.core.Vertx;\n+import io.vertx.core.http.HttpMethod;\n+import io.vertx.core.http.HttpServer;\n+import io.vertx.ext.web.Router;\n+import io.vertx.ext.web.RoutingContext;\n+import org.reflections.Reflections;\n+\n+import java.lang.reflect.Modifier;\n+import java.util.Set;\n+\n+public class EntryPoint {\n+\n+    private final Vertx vertx;\n+\n+    private final Router router;\n+\n+    // TODO move config from external file\n+    private int PORT = 8080;\n+\n+    public static void main(String[] args) {\n+        Injector injector = Guice.createInjector(new BoostrapBinder());\n+        EntryPoint entryPoint = injector.getInstance(EntryPoint.class);\n+        entryPoint.initialize(injector);\n+        entryPoint.run();\n+    }\n+\n+    @Inject\n+    public EntryPoint(Vertx vertx, Router router) {\n+        this.vertx = vertx;\n+        this.router = router;\n+    }\n+\n+    public void initialize(Injector injector) {\n+        initHandlers(injector);\n+    }\n+\n+    private void initHandlers(Injector injector) {\n+\n+        // init core handlers\n+        initOAuth2(injector);\n+        initCustomHandlers(injector);\n+    }\n+\n+    private void initOAuth2(Injector injector) {\n+        Reflections reflections = new Reflections(\"imbrobits.loosh.handler\");\n+        Set<Class<? extends IOAuth2Handler>> oauthHandlers = reflections.getSubTypesOf(IOAuth2Handler.class);\n+        oauthHandlers.stream().forEach(auth -> {\n+            if (!Modifier.isAbstract(auth.getModifiers())) {\n+                IOAuth2Handler instance = injector.getInstance(auth);\n+                router.route(instance.authenticationUri()).handler(instance.authenticate());\n+                router.route(instance.callbackUri()).handler(instance.callback());\n+            }\n+        });\n+    }\n+\n+    private void initCustomHandlers(Injector injector) {\n+        Reflections reflections = new Reflections(\"imbrobits.loosh.handler\");\n+        Set<Class<?>> handlers = reflections.getTypesAnnotatedWith(Controller.class);\n+\n+        handlers.forEach(cls -> {\n+            Handler<RoutingContext> handler = (Handler<RoutingContext>) injector.getInstance(cls);\n+            String path = handler.getClass().getAnnotation(Controller.class).path();\n+            HttpMethod method = handler.getClass().getAnnotation(Controller.class).method();\n+            if (router.getRoutes().contains(path)) {","path":"src/main/java/imbrobits/loosh/core/EntryPoint.java","position":96,"original_position":96,"commit_id":"2e71bd02465382062f50edcd2e7d0c22857b1471","original_commit_id":"2e71bd02465382062f50edcd2e7d0c22857b1471","user":{"login":"sputnikci","id":15047461,"avatar_url":"https://avatars.githubusercontent.com/u/15047461?v=3","gravatar_id":"","url":"https://api.github.com/users/sputnikci","html_url":"https://github.com/sputnikci","followers_url":"https://api.github.com/users/sputnikci/followers","following_url":"https://api.github.com/users/sputnikci/following{/other_user}","gists_url":"https://api.github.com/users/sputnikci/gists{/gist_id}","starred_url":"https://api.github.com/users/sputnikci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sputnikci/subscriptions","organizations_url":"https://api.github.com/users/sputnikci/orgs","repos_url":"https://api.github.com/users/sputnikci/repos","events_url":"https://api.github.com/users/sputnikci/events{/privacy}","received_events_url":"https://api.github.com/users/sputnikci/received_events","type":"User","site_admin":false},"body":"\\[Checkstyle\\] ERROR: Must have at least one statement\\.","created_at":"2016-09-17T19:07:28Z","updated_at":"2016-09-17T19:07:28Z","html_url":"https://github.com/imbrobits/loosh/pull/3#discussion_r79290139","pull_request_url":"https://api.github.com/repos/imbrobits/loosh/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/imbrobits/loosh/pulls/comments/79290139"},"html":{"href":"https://github.com/imbrobits/loosh/pull/3#discussion_r79290139"},"pull_request":{"href":"https://api.github.com/repos/imbrobits/loosh/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/imbrobits/loosh/pulls/3","id":85683677,"html_url":"https://github.com/imbrobits/loosh/pull/3","diff_url":"https://github.com/imbrobits/loosh/pull/3.diff","patch_url":"https://github.com/imbrobits/loosh/pull/3.patch","issue_url":"https://api.github.com/repos/imbrobits/loosh/issues/3","number":3,"state":"open","locked":false,"title":"Implement OAuth2 handler","user":{"login":"imbrobits","id":6501201,"avatar_url":"https://avatars.githubusercontent.com/u/6501201?v=3","gravatar_id":"","url":"https://api.github.com/users/imbrobits","html_url":"https://github.com/imbrobits","followers_url":"https://api.github.com/users/imbrobits/followers","following_url":"https://api.github.com/users/imbrobits/following{/other_user}","gists_url":"https://api.github.com/users/imbrobits/gists{/gist_id}","starred_url":"https://api.github.com/users/imbrobits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imbrobits/subscriptions","organizations_url":"https://api.github.com/users/imbrobits/orgs","repos_url":"https://api.github.com/users/imbrobits/repos","events_url":"https://api.github.com/users/imbrobits/events{/privacy}","received_events_url":"https://api.github.com/users/imbrobits/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-17T19:04:59Z","updated_at":"2016-09-17T19:07:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fb484b01652b64edff860e2d659c800feccc1d26","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/imbrobits/loosh/pulls/3/commits","review_comments_url":"https://api.github.com/repos/imbrobits/loosh/pulls/3/comments","review_comment_url":"https://api.github.com/repos/imbrobits/loosh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/imbrobits/loosh/issues/3/comments","statuses_url":"https://api.github.com/repos/imbrobits/loosh/statuses/2e71bd02465382062f50edcd2e7d0c22857b1471","head":{"label":"imbrobits:dev","ref":"dev","sha":"2e71bd02465382062f50edcd2e7d0c22857b1471","user":{"login":"imbrobits","id":6501201,"avatar_url":"https://avatars.githubusercontent.com/u/6501201?v=3","gravatar_id":"","url":"https://api.github.com/users/imbrobits","html_url":"https://github.com/imbrobits","followers_url":"https://api.github.com/users/imbrobits/followers","following_url":"https://api.github.com/users/imbrobits/following{/other_user}","gists_url":"https://api.github.com/users/imbrobits/gists{/gist_id}","starred_url":"https://api.github.com/users/imbrobits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imbrobits/subscriptions","organizations_url":"https://api.github.com/users/imbrobits/orgs","repos_url":"https://api.github.com/users/imbrobits/repos","events_url":"https://api.github.com/users/imbrobits/events{/privacy}","received_events_url":"https://api.github.com/users/imbrobits/received_events","type":"User","site_admin":false},"repo":{"id":67506000,"name":"loosh","full_name":"imbrobits/loosh","owner":{"login":"imbrobits","id":6501201,"avatar_url":"https://avatars.githubusercontent.com/u/6501201?v=3","gravatar_id":"","url":"https://api.github.com/users/imbrobits","html_url":"https://github.com/imbrobits","followers_url":"https://api.github.com/users/imbrobits/followers","following_url":"https://api.github.com/users/imbrobits/following{/other_user}","gists_url":"https://api.github.com/users/imbrobits/gists{/gist_id}","starred_url":"https://api.github.com/users/imbrobits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imbrobits/subscriptions","organizations_url":"https://api.github.com/users/imbrobits/orgs","repos_url":"https://api.github.com/users/imbrobits/repos","events_url":"https://api.github.com/users/imbrobits/events{/privacy}","received_events_url":"https://api.github.com/users/imbrobits/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/imbrobits/loosh","description":"Personal dashboard","fork":false,"url":"https://api.github.com/repos/imbrobits/loosh","forks_url":"https://api.github.com/repos/imbrobits/loosh/forks","keys_url":"https://api.github.com/repos/imbrobits/loosh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/imbrobits/loosh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/imbrobits/loosh/teams","hooks_url":"https://api.github.com/repos/imbrobits/loosh/hooks","issue_events_url":"https://api.github.com/repos/imbrobits/loosh/issues/events{/number}","events_url":"https://api.github.com/repos/imbrobits/loosh/events","assignees_url":"https://api.github.com/repos/imbrobits/loosh/assignees{/user}","branches_url":"https://api.github.com/repos/imbrobits/loosh/branches{/branch}","tags_url":"https://api.github.com/repos/imbrobits/loosh/tags","blobs_url":"https://api.github.com/repos/imbrobits/loosh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/imbrobits/loosh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/imbrobits/loosh/git/refs{/sha}","trees_url":"https://api.github.com/repos/imbrobits/loosh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/imbrobits/loosh/statuses/{sha}","languages_url":"https://api.github.com/repos/imbrobits/loosh/languages","stargazers_url":"https://api.github.com/repos/imbrobits/loosh/stargazers","contributors_url":"https://api.github.com/repos/imbrobits/loosh/contributors","subscribers_url":"https://api.github.com/repos/imbrobits/loosh/subscribers","subscription_url":"https://api.github.com/repos/imbrobits/loosh/subscription","commits_url":"https://api.github.com/repos/imbrobits/loosh/commits{/sha}","git_commits_url":"https://api.github.com/repos/imbrobits/loosh/git/commits{/sha}","comments_url":"https://api.github.com/repos/imbrobits/loosh/comments{/number}","issue_comment_url":"https://api.github.com/repos/imbrobits/loosh/issues/comments{/number}","contents_url":"https://api.github.com/repos/imbrobits/loosh/contents/{+path}","compare_url":"https://api.github.com/repos/imbrobits/loosh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/imbrobits/loosh/merges","archive_url":"https://api.github.com/repos/imbrobits/loosh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/imbrobits/loosh/downloads","issues_url":"https://api.github.com/repos/imbrobits/loosh/issues{/number}","pulls_url":"https://api.github.com/repos/imbrobits/loosh/pulls{/number}","milestones_url":"https://api.github.com/repos/imbrobits/loosh/milestones{/number}","notifications_url":"https://api.github.com/repos/imbrobits/loosh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/imbrobits/loosh/labels{/name}","releases_url":"https://api.github.com/repos/imbrobits/loosh/releases{/id}","deployments_url":"https://api.github.com/repos/imbrobits/loosh/deployments","created_at":"2016-09-06T12:26:52Z","updated_at":"2016-09-06T12:30:51Z","pushed_at":"2016-09-17T19:07:25Z","git_url":"git://github.com/imbrobits/loosh.git","ssh_url":"git@github.com:imbrobits/loosh.git","clone_url":"https://github.com/imbrobits/loosh.git","svn_url":"https://github.com/imbrobits/loosh","homepage":null,"size":70,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"imbrobits:master","ref":"master","sha":"d3995bc2eea5ad405ff1e332abe08c0f6f7c3b93","user":{"login":"imbrobits","id":6501201,"avatar_url":"https://avatars.githubusercontent.com/u/6501201?v=3","gravatar_id":"","url":"https://api.github.com/users/imbrobits","html_url":"https://github.com/imbrobits","followers_url":"https://api.github.com/users/imbrobits/followers","following_url":"https://api.github.com/users/imbrobits/following{/other_user}","gists_url":"https://api.github.com/users/imbrobits/gists{/gist_id}","starred_url":"https://api.github.com/users/imbrobits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imbrobits/subscriptions","organizations_url":"https://api.github.com/users/imbrobits/orgs","repos_url":"https://api.github.com/users/imbrobits/repos","events_url":"https://api.github.com/users/imbrobits/events{/privacy}","received_events_url":"https://api.github.com/users/imbrobits/received_events","type":"User","site_admin":false},"repo":{"id":67506000,"name":"loosh","full_name":"imbrobits/loosh","owner":{"login":"imbrobits","id":6501201,"avatar_url":"https://avatars.githubusercontent.com/u/6501201?v=3","gravatar_id":"","url":"https://api.github.com/users/imbrobits","html_url":"https://github.com/imbrobits","followers_url":"https://api.github.com/users/imbrobits/followers","following_url":"https://api.github.com/users/imbrobits/following{/other_user}","gists_url":"https://api.github.com/users/imbrobits/gists{/gist_id}","starred_url":"https://api.github.com/users/imbrobits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imbrobits/subscriptions","organizations_url":"https://api.github.com/users/imbrobits/orgs","repos_url":"https://api.github.com/users/imbrobits/repos","events_url":"https://api.github.com/users/imbrobits/events{/privacy}","received_events_url":"https://api.github.com/users/imbrobits/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/imbrobits/loosh","description":"Personal dashboard","fork":false,"url":"https://api.github.com/repos/imbrobits/loosh","forks_url":"https://api.github.com/repos/imbrobits/loosh/forks","keys_url":"https://api.github.com/repos/imbrobits/loosh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/imbrobits/loosh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/imbrobits/loosh/teams","hooks_url":"https://api.github.com/repos/imbrobits/loosh/hooks","issue_events_url":"https://api.github.com/repos/imbrobits/loosh/issues/events{/number}","events_url":"https://api.github.com/repos/imbrobits/loosh/events","assignees_url":"https://api.github.com/repos/imbrobits/loosh/assignees{/user}","branches_url":"https://api.github.com/repos/imbrobits/loosh/branches{/branch}","tags_url":"https://api.github.com/repos/imbrobits/loosh/tags","blobs_url":"https://api.github.com/repos/imbrobits/loosh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/imbrobits/loosh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/imbrobits/loosh/git/refs{/sha}","trees_url":"https://api.github.com/repos/imbrobits/loosh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/imbrobits/loosh/statuses/{sha}","languages_url":"https://api.github.com/repos/imbrobits/loosh/languages","stargazers_url":"https://api.github.com/repos/imbrobits/loosh/stargazers","contributors_url":"https://api.github.com/repos/imbrobits/loosh/contributors","subscribers_url":"https://api.github.com/repos/imbrobits/loosh/subscribers","subscription_url":"https://api.github.com/repos/imbrobits/loosh/subscription","commits_url":"https://api.github.com/repos/imbrobits/loosh/commits{/sha}","git_commits_url":"https://api.github.com/repos/imbrobits/loosh/git/commits{/sha}","comments_url":"https://api.github.com/repos/imbrobits/loosh/comments{/number}","issue_comment_url":"https://api.github.com/repos/imbrobits/loosh/issues/comments{/number}","contents_url":"https://api.github.com/repos/imbrobits/loosh/contents/{+path}","compare_url":"https://api.github.com/repos/imbrobits/loosh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/imbrobits/loosh/merges","archive_url":"https://api.github.com/repos/imbrobits/loosh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/imbrobits/loosh/downloads","issues_url":"https://api.github.com/repos/imbrobits/loosh/issues{/number}","pulls_url":"https://api.github.com/repos/imbrobits/loosh/pulls{/number}","milestones_url":"https://api.github.com/repos/imbrobits/loosh/milestones{/number}","notifications_url":"https://api.github.com/repos/imbrobits/loosh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/imbrobits/loosh/labels{/name}","releases_url":"https://api.github.com/repos/imbrobits/loosh/releases{/id}","deployments_url":"https://api.github.com/repos/imbrobits/loosh/deployments","created_at":"2016-09-06T12:26:52Z","updated_at":"2016-09-06T12:30:51Z","pushed_at":"2016-09-17T19:07:25Z","git_url":"git://github.com/imbrobits/loosh.git","ssh_url":"git@github.com:imbrobits/loosh.git","clone_url":"https://github.com/imbrobits/loosh.git","svn_url":"https://github.com/imbrobits/loosh","homepage":null,"size":70,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/imbrobits/loosh/pulls/3"},"html":{"href":"https://github.com/imbrobits/loosh/pull/3"},"issue":{"href":"https://api.github.com/repos/imbrobits/loosh/issues/3"},"comments":{"href":"https://api.github.com/repos/imbrobits/loosh/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/imbrobits/loosh/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/imbrobits/loosh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/imbrobits/loosh/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/imbrobits/loosh/statuses/2e71bd02465382062f50edcd2e7d0c22857b1471"}}}}
{"actor":{"display_login":"sputnikci"}}