{"action":"created","comment":{"url":"https://api.github.com/repos/MollieS/HTTPServer/pulls/comments/80357474","id":80357474,"diff_hunk":"@@ -0,0 +1,27 @@\n+package httpserver.httpmessages;\n+\n+import httpserver.ResourceHandler;\n+import httpserver.ResponseBuilder;\n+import httpserver.resourcemanagement.Resource;\n+\n+import static httpserver.httpmessages.HTTPResponses.*;\n+\n+public class HTTPResponseBuilder implements ResponseBuilder {\n+\n+    private final ResourceHandler resourceHandler;\n+\n+    public HTTPResponseBuilder(ResourceHandler resourceHandler) {\n+        this.resourceHandler = resourceHandler;\n+    }\n+\n+    public HTTPResponse buildResponse(String method, String path) {\n+        Resource resource = resourceHandler.getResource(path);\n+        if (resource.exists()) {\n+            HTTPResponse httpResponse = new HTTPResponse(OK.code, OK.reason);\n+            httpResponse.setContentType(resource.getContentType());\n+            httpResponse.setBody(resource.getContents());\n+            return httpResponse;\n+        }\n+        return new HTTPResponse(NOTFOUND.code, NOTFOUND.reason);","path":"src/main/java/httpserver/httpmessages/HTTPResponseBuilder.java","position":25,"original_position":25,"commit_id":"d34c0ad64ef0dff11d8b5811dde9c71826f03311","original_commit_id":"d34c0ad64ef0dff11d8b5811dde9c71826f03311","user":{"login":"felipesere","id":1850188,"avatar_url":"https://avatars.githubusercontent.com/u/1850188?v=3","gravatar_id":"","url":"https://api.github.com/users/felipesere","html_url":"https://github.com/felipesere","followers_url":"https://api.github.com/users/felipesere/followers","following_url":"https://api.github.com/users/felipesere/following{/other_user}","gists_url":"https://api.github.com/users/felipesere/gists{/gist_id}","starred_url":"https://api.github.com/users/felipesere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felipesere/subscriptions","organizations_url":"https://api.github.com/users/felipesere/orgs","repos_url":"https://api.github.com/users/felipesere/repos","events_url":"https://api.github.com/users/felipesere/events{/privacy}","received_events_url":"https://api.github.com/users/felipesere/received_events","type":"User","site_admin":false},"body":"I would go _eeeeven_ further:\r\n\r\n```\r\nif (resource.exists()) {\r\n ...\r\n} else {\r\n  return new NotFound();\r\n}","created_at":"2016-09-24T09:30:17Z","updated_at":"2016-09-24T09:43:19Z","html_url":"https://github.com/MollieS/HTTPServer/pull/2#discussion_r80357474","pull_request_url":"https://api.github.com/repos/MollieS/HTTPServer/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/MollieS/HTTPServer/pulls/comments/80357474"},"html":{"href":"https://github.com/MollieS/HTTPServer/pull/2#discussion_r80357474"},"pull_request":{"href":"https://api.github.com/repos/MollieS/HTTPServer/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/MollieS/HTTPServer/pulls/2","id":86351934,"html_url":"https://github.com/MollieS/HTTPServer/pull/2","diff_url":"https://github.com/MollieS/HTTPServer/pull/2.diff","patch_url":"https://github.com/MollieS/HTTPServer/pull/2.patch","issue_url":"https://api.github.com/repos/MollieS/HTTPServer/issues/2","number":2,"state":"open","locked":false,"title":"Files","user":{"login":"MollieS","id":11349388,"avatar_url":"https://avatars.githubusercontent.com/u/11349388?v=3","gravatar_id":"","url":"https://api.github.com/users/MollieS","html_url":"https://github.com/MollieS","followers_url":"https://api.github.com/users/MollieS/followers","following_url":"https://api.github.com/users/MollieS/following{/other_user}","gists_url":"https://api.github.com/users/MollieS/gists{/gist_id}","starred_url":"https://api.github.com/users/MollieS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MollieS/subscriptions","organizations_url":"https://api.github.com/users/MollieS/orgs","repos_url":"https://api.github.com/users/MollieS/repos","events_url":"https://api.github.com/users/MollieS/events{/privacy}","received_events_url":"https://api.github.com/users/MollieS/received_events","type":"User","site_admin":false},"body":"- can make a get request to files\r\n- receive a 404 response if file not found\r\n- can view images and get correct content-type","created_at":"2016-09-22T14:46:23Z","updated_at":"2016-09-24T09:43:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"210a4772bd5dbaeae4d09b14af412f5d60c5d872","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/MollieS/HTTPServer/pulls/2/commits","review_comments_url":"https://api.github.com/repos/MollieS/HTTPServer/pulls/2/comments","review_comment_url":"https://api.github.com/repos/MollieS/HTTPServer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MollieS/HTTPServer/issues/2/comments","statuses_url":"https://api.github.com/repos/MollieS/HTTPServer/statuses/d34c0ad64ef0dff11d8b5811dde9c71826f03311","head":{"label":"MollieS:files","ref":"files","sha":"d34c0ad64ef0dff11d8b5811dde9c71826f03311","user":{"login":"MollieS","id":11349388,"avatar_url":"https://avatars.githubusercontent.com/u/11349388?v=3","gravatar_id":"","url":"https://api.github.com/users/MollieS","html_url":"https://github.com/MollieS","followers_url":"https://api.github.com/users/MollieS/followers","following_url":"https://api.github.com/users/MollieS/following{/other_user}","gists_url":"https://api.github.com/users/MollieS/gists{/gist_id}","starred_url":"https://api.github.com/users/MollieS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MollieS/subscriptions","organizations_url":"https://api.github.com/users/MollieS/orgs","repos_url":"https://api.github.com/users/MollieS/repos","events_url":"https://api.github.com/users/MollieS/events{/privacy}","received_events_url":"https://api.github.com/users/MollieS/received_events","type":"User","site_admin":false},"repo":{"id":68689961,"name":"HTTPServer","full_name":"MollieS/HTTPServer","owner":{"login":"MollieS","id":11349388,"avatar_url":"https://avatars.githubusercontent.com/u/11349388?v=3","gravatar_id":"","url":"https://api.github.com/users/MollieS","html_url":"https://github.com/MollieS","followers_url":"https://api.github.com/users/MollieS/followers","following_url":"https://api.github.com/users/MollieS/following{/other_user}","gists_url":"https://api.github.com/users/MollieS/gists{/gist_id}","starred_url":"https://api.github.com/users/MollieS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MollieS/subscriptions","organizations_url":"https://api.github.com/users/MollieS/orgs","repos_url":"https://api.github.com/users/MollieS/repos","events_url":"https://api.github.com/users/MollieS/events{/privacy}","received_events_url":"https://api.github.com/users/MollieS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MollieS/HTTPServer","description":null,"fork":false,"url":"https://api.github.com/repos/MollieS/HTTPServer","forks_url":"https://api.github.com/repos/MollieS/HTTPServer/forks","keys_url":"https://api.github.com/repos/MollieS/HTTPServer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MollieS/HTTPServer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MollieS/HTTPServer/teams","hooks_url":"https://api.github.com/repos/MollieS/HTTPServer/hooks","issue_events_url":"https://api.github.com/repos/MollieS/HTTPServer/issues/events{/number}","events_url":"https://api.github.com/repos/MollieS/HTTPServer/events","assignees_url":"https://api.github.com/repos/MollieS/HTTPServer/assignees{/user}","branches_url":"https://api.github.com/repos/MollieS/HTTPServer/branches{/branch}","tags_url":"https://api.github.com/repos/MollieS/HTTPServer/tags","blobs_url":"https://api.github.com/repos/MollieS/HTTPServer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MollieS/HTTPServer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MollieS/HTTPServer/git/refs{/sha}","trees_url":"https://api.github.com/repos/MollieS/HTTPServer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MollieS/HTTPServer/statuses/{sha}","languages_url":"https://api.github.com/repos/MollieS/HTTPServer/languages","stargazers_url":"https://api.github.com/repos/MollieS/HTTPServer/stargazers","contributors_url":"https://api.github.com/repos/MollieS/HTTPServer/contributors","subscribers_url":"https://api.github.com/repos/MollieS/HTTPServer/subscribers","subscription_url":"https://api.github.com/repos/MollieS/HTTPServer/subscription","commits_url":"https://api.github.com/repos/MollieS/HTTPServer/commits{/sha}","git_commits_url":"https://api.github.com/repos/MollieS/HTTPServer/git/commits{/sha}","comments_url":"https://api.github.com/repos/MollieS/HTTPServer/comments{/number}","issue_comment_url":"https://api.github.com/repos/MollieS/HTTPServer/issues/comments{/number}","contents_url":"https://api.github.com/repos/MollieS/HTTPServer/contents/{+path}","compare_url":"https://api.github.com/repos/MollieS/HTTPServer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MollieS/HTTPServer/merges","archive_url":"https://api.github.com/repos/MollieS/HTTPServer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MollieS/HTTPServer/downloads","issues_url":"https://api.github.com/repos/MollieS/HTTPServer/issues{/number}","pulls_url":"https://api.github.com/repos/MollieS/HTTPServer/pulls{/number}","milestones_url":"https://api.github.com/repos/MollieS/HTTPServer/milestones{/number}","notifications_url":"https://api.github.com/repos/MollieS/HTTPServer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MollieS/HTTPServer/labels{/name}","releases_url":"https://api.github.com/repos/MollieS/HTTPServer/releases{/id}","deployments_url":"https://api.github.com/repos/MollieS/HTTPServer/deployments","created_at":"2016-09-20T08:16:34Z","updated_at":"2016-09-22T08:34:05Z","pushed_at":"2016-09-22T14:46:23Z","git_url":"git://github.com/MollieS/HTTPServer.git","ssh_url":"git@github.com:MollieS/HTTPServer.git","clone_url":"https://github.com/MollieS/HTTPServer.git","svn_url":"https://github.com/MollieS/HTTPServer","homepage":null,"size":408,"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":"MollieS:master","ref":"master","sha":"f28d9e77566342918f001c9edd12f56fec72abbf","user":{"login":"MollieS","id":11349388,"avatar_url":"https://avatars.githubusercontent.com/u/11349388?v=3","gravatar_id":"","url":"https://api.github.com/users/MollieS","html_url":"https://github.com/MollieS","followers_url":"https://api.github.com/users/MollieS/followers","following_url":"https://api.github.com/users/MollieS/following{/other_user}","gists_url":"https://api.github.com/users/MollieS/gists{/gist_id}","starred_url":"https://api.github.com/users/MollieS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MollieS/subscriptions","organizations_url":"https://api.github.com/users/MollieS/orgs","repos_url":"https://api.github.com/users/MollieS/repos","events_url":"https://api.github.com/users/MollieS/events{/privacy}","received_events_url":"https://api.github.com/users/MollieS/received_events","type":"User","site_admin":false},"repo":{"id":68689961,"name":"HTTPServer","full_name":"MollieS/HTTPServer","owner":{"login":"MollieS","id":11349388,"avatar_url":"https://avatars.githubusercontent.com/u/11349388?v=3","gravatar_id":"","url":"https://api.github.com/users/MollieS","html_url":"https://github.com/MollieS","followers_url":"https://api.github.com/users/MollieS/followers","following_url":"https://api.github.com/users/MollieS/following{/other_user}","gists_url":"https://api.github.com/users/MollieS/gists{/gist_id}","starred_url":"https://api.github.com/users/MollieS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MollieS/subscriptions","organizations_url":"https://api.github.com/users/MollieS/orgs","repos_url":"https://api.github.com/users/MollieS/repos","events_url":"https://api.github.com/users/MollieS/events{/privacy}","received_events_url":"https://api.github.com/users/MollieS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MollieS/HTTPServer","description":null,"fork":false,"url":"https://api.github.com/repos/MollieS/HTTPServer","forks_url":"https://api.github.com/repos/MollieS/HTTPServer/forks","keys_url":"https://api.github.com/repos/MollieS/HTTPServer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MollieS/HTTPServer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MollieS/HTTPServer/teams","hooks_url":"https://api.github.com/repos/MollieS/HTTPServer/hooks","issue_events_url":"https://api.github.com/repos/MollieS/HTTPServer/issues/events{/number}","events_url":"https://api.github.com/repos/MollieS/HTTPServer/events","assignees_url":"https://api.github.com/repos/MollieS/HTTPServer/assignees{/user}","branches_url":"https://api.github.com/repos/MollieS/HTTPServer/branches{/branch}","tags_url":"https://api.github.com/repos/MollieS/HTTPServer/tags","blobs_url":"https://api.github.com/repos/MollieS/HTTPServer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MollieS/HTTPServer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MollieS/HTTPServer/git/refs{/sha}","trees_url":"https://api.github.com/repos/MollieS/HTTPServer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MollieS/HTTPServer/statuses/{sha}","languages_url":"https://api.github.com/repos/MollieS/HTTPServer/languages","stargazers_url":"https://api.github.com/repos/MollieS/HTTPServer/stargazers","contributors_url":"https://api.github.com/repos/MollieS/HTTPServer/contributors","subscribers_url":"https://api.github.com/repos/MollieS/HTTPServer/subscribers","subscription_url":"https://api.github.com/repos/MollieS/HTTPServer/subscription","commits_url":"https://api.github.com/repos/MollieS/HTTPServer/commits{/sha}","git_commits_url":"https://api.github.com/repos/MollieS/HTTPServer/git/commits{/sha}","comments_url":"https://api.github.com/repos/MollieS/HTTPServer/comments{/number}","issue_comment_url":"https://api.github.com/repos/MollieS/HTTPServer/issues/comments{/number}","contents_url":"https://api.github.com/repos/MollieS/HTTPServer/contents/{+path}","compare_url":"https://api.github.com/repos/MollieS/HTTPServer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MollieS/HTTPServer/merges","archive_url":"https://api.github.com/repos/MollieS/HTTPServer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MollieS/HTTPServer/downloads","issues_url":"https://api.github.com/repos/MollieS/HTTPServer/issues{/number}","pulls_url":"https://api.github.com/repos/MollieS/HTTPServer/pulls{/number}","milestones_url":"https://api.github.com/repos/MollieS/HTTPServer/milestones{/number}","notifications_url":"https://api.github.com/repos/MollieS/HTTPServer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MollieS/HTTPServer/labels{/name}","releases_url":"https://api.github.com/repos/MollieS/HTTPServer/releases{/id}","deployments_url":"https://api.github.com/repos/MollieS/HTTPServer/deployments","created_at":"2016-09-20T08:16:34Z","updated_at":"2016-09-22T08:34:05Z","pushed_at":"2016-09-22T14:46:23Z","git_url":"git://github.com/MollieS/HTTPServer.git","ssh_url":"git@github.com:MollieS/HTTPServer.git","clone_url":"https://github.com/MollieS/HTTPServer.git","svn_url":"https://github.com/MollieS/HTTPServer","homepage":null,"size":408,"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/MollieS/HTTPServer/pulls/2"},"html":{"href":"https://github.com/MollieS/HTTPServer/pull/2"},"issue":{"href":"https://api.github.com/repos/MollieS/HTTPServer/issues/2"},"comments":{"href":"https://api.github.com/repos/MollieS/HTTPServer/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/MollieS/HTTPServer/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/MollieS/HTTPServer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MollieS/HTTPServer/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/MollieS/HTTPServer/statuses/d34c0ad64ef0dff11d8b5811dde9c71826f03311"}}}}
{"actor":{"display_login":"felipesere"}}