{"action":"created","comment":{"url":"https://api.github.com/repos/parkr/ping/pulls/comments/68125553","id":68125553,"diff_hunk":"@@ -84,10 +84,20 @@ func ping(w http.ResponseWriter, r *http.Request) {\n \t\tip = r.RemoteAddr\n \t}\n \n+\tvar ua string\n+\tif res := r.Header.Get(\"User-Agent\"); res != \"\" {\n+\t\tua = res\n+\t} else {\n+\t\tlog.Println(\"empty user-agent\")\n+\t\tjavascriptRespond(w, http.StatusBadRequest, \"empty user-agent\")\n+\t\treturn\n+\t}","path":"ping.go","position":11,"original_position":11,"commit_id":"baaab09c44dd16cf7fb3964d91ce4d89cd275c15","original_commit_id":"baaab09c44dd16cf7fb3964d91ce4d89cd275c15","user":{"login":"parkr","id":237985,"avatar_url":"https://avatars.githubusercontent.com/u/237985?v=3","gravatar_id":"","url":"https://api.github.com/users/parkr","html_url":"https://github.com/parkr","followers_url":"https://api.github.com/users/parkr/followers","following_url":"https://api.github.com/users/parkr/following{/other_user}","gists_url":"https://api.github.com/users/parkr/gists{/gist_id}","starred_url":"https://api.github.com/users/parkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkr/subscriptions","organizations_url":"https://api.github.com/users/parkr/orgs","repos_url":"https://api.github.com/users/parkr/repos","events_url":"https://api.github.com/users/parkr/events{/privacy}","received_events_url":"https://api.github.com/users/parkr/received_events","type":"User","site_admin":true},"body":"I think I would refactor this into:\r\n\r\n```go\r\nuserAgent := r.Header.Get(\"User-Agent\")\r\nif userAgent == \"\" {\r\n    log.Println(\"empty user-agent\")\r\n    javascriptRespond(w, http.StatusBadRequest, \"empty user-agent\")\r\n    return\r\n}\r\n```\r\n\r\nI think it's a bit more direct that way. What do you think?","created_at":"2016-06-22T20:10:11Z","updated_at":"2016-06-22T20:10:11Z","html_url":"https://github.com/parkr/ping/pull/3#discussion_r68125553","pull_request_url":"https://api.github.com/repos/parkr/ping/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/parkr/ping/pulls/comments/68125553"},"html":{"href":"https://github.com/parkr/ping/pull/3#discussion_r68125553"},"pull_request":{"href":"https://api.github.com/repos/parkr/ping/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/parkr/ping/pulls/3","id":74818732,"html_url":"https://github.com/parkr/ping/pull/3","diff_url":"https://github.com/parkr/ping/pull/3.diff","patch_url":"https://github.com/parkr/ping/pull/3.patch","issue_url":"https://api.github.com/repos/parkr/ping/issues/3","number":3,"state":"open","locked":false,"title":"Added user-agent to visits","user":{"login":"jrasanen","id":13303,"avatar_url":"https://avatars.githubusercontent.com/u/13303?v=3","gravatar_id":"","url":"https://api.github.com/users/jrasanen","html_url":"https://github.com/jrasanen","followers_url":"https://api.github.com/users/jrasanen/followers","following_url":"https://api.github.com/users/jrasanen/following{/other_user}","gists_url":"https://api.github.com/users/jrasanen/gists{/gist_id}","starred_url":"https://api.github.com/users/jrasanen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrasanen/subscriptions","organizations_url":"https://api.github.com/users/jrasanen/orgs","repos_url":"https://api.github.com/users/jrasanen/repos","events_url":"https://api.github.com/users/jrasanen/events{/privacy}","received_events_url":"https://api.github.com/users/jrasanen/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-22T16:49:17Z","updated_at":"2016-06-22T20:10:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4ecbfbe5d72c4a8f3aff2e45a3938b47392a632","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/parkr/ping/pulls/3/commits","review_comments_url":"https://api.github.com/repos/parkr/ping/pulls/3/comments","review_comment_url":"https://api.github.com/repos/parkr/ping/pulls/comments{/number}","comments_url":"https://api.github.com/repos/parkr/ping/issues/3/comments","statuses_url":"https://api.github.com/repos/parkr/ping/statuses/baaab09c44dd16cf7fb3964d91ce4d89cd275c15","head":{"label":"jrasanen:master","ref":"master","sha":"baaab09c44dd16cf7fb3964d91ce4d89cd275c15","user":{"login":"jrasanen","id":13303,"avatar_url":"https://avatars.githubusercontent.com/u/13303?v=3","gravatar_id":"","url":"https://api.github.com/users/jrasanen","html_url":"https://github.com/jrasanen","followers_url":"https://api.github.com/users/jrasanen/followers","following_url":"https://api.github.com/users/jrasanen/following{/other_user}","gists_url":"https://api.github.com/users/jrasanen/gists{/gist_id}","starred_url":"https://api.github.com/users/jrasanen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrasanen/subscriptions","organizations_url":"https://api.github.com/users/jrasanen/orgs","repos_url":"https://api.github.com/users/jrasanen/repos","events_url":"https://api.github.com/users/jrasanen/events{/privacy}","received_events_url":"https://api.github.com/users/jrasanen/received_events","type":"User","site_admin":false},"repo":{"id":61734711,"name":"ping","full_name":"jrasanen/ping","owner":{"login":"jrasanen","id":13303,"avatar_url":"https://avatars.githubusercontent.com/u/13303?v=3","gravatar_id":"","url":"https://api.github.com/users/jrasanen","html_url":"https://github.com/jrasanen","followers_url":"https://api.github.com/users/jrasanen/followers","following_url":"https://api.github.com/users/jrasanen/following{/other_user}","gists_url":"https://api.github.com/users/jrasanen/gists{/gist_id}","starred_url":"https://api.github.com/users/jrasanen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrasanen/subscriptions","organizations_url":"https://api.github.com/users/jrasanen/orgs","repos_url":"https://api.github.com/users/jrasanen/repos","events_url":"https://api.github.com/users/jrasanen/events{/privacy}","received_events_url":"https://api.github.com/users/jrasanen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jrasanen/ping","description":":bar_chart: Your very own Google Analytics replacement, without all of the Google. Simple as pie.","fork":true,"url":"https://api.github.com/repos/jrasanen/ping","forks_url":"https://api.github.com/repos/jrasanen/ping/forks","keys_url":"https://api.github.com/repos/jrasanen/ping/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jrasanen/ping/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jrasanen/ping/teams","hooks_url":"https://api.github.com/repos/jrasanen/ping/hooks","issue_events_url":"https://api.github.com/repos/jrasanen/ping/issues/events{/number}","events_url":"https://api.github.com/repos/jrasanen/ping/events","assignees_url":"https://api.github.com/repos/jrasanen/ping/assignees{/user}","branches_url":"https://api.github.com/repos/jrasanen/ping/branches{/branch}","tags_url":"https://api.github.com/repos/jrasanen/ping/tags","blobs_url":"https://api.github.com/repos/jrasanen/ping/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jrasanen/ping/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jrasanen/ping/git/refs{/sha}","trees_url":"https://api.github.com/repos/jrasanen/ping/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jrasanen/ping/statuses/{sha}","languages_url":"https://api.github.com/repos/jrasanen/ping/languages","stargazers_url":"https://api.github.com/repos/jrasanen/ping/stargazers","contributors_url":"https://api.github.com/repos/jrasanen/ping/contributors","subscribers_url":"https://api.github.com/repos/jrasanen/ping/subscribers","subscription_url":"https://api.github.com/repos/jrasanen/ping/subscription","commits_url":"https://api.github.com/repos/jrasanen/ping/commits{/sha}","git_commits_url":"https://api.github.com/repos/jrasanen/ping/git/commits{/sha}","comments_url":"https://api.github.com/repos/jrasanen/ping/comments{/number}","issue_comment_url":"https://api.github.com/repos/jrasanen/ping/issues/comments{/number}","contents_url":"https://api.github.com/repos/jrasanen/ping/contents/{+path}","compare_url":"https://api.github.com/repos/jrasanen/ping/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jrasanen/ping/merges","archive_url":"https://api.github.com/repos/jrasanen/ping/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jrasanen/ping/downloads","issues_url":"https://api.github.com/repos/jrasanen/ping/issues{/number}","pulls_url":"https://api.github.com/repos/jrasanen/ping/pulls{/number}","milestones_url":"https://api.github.com/repos/jrasanen/ping/milestones{/number}","notifications_url":"https://api.github.com/repos/jrasanen/ping/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jrasanen/ping/labels{/name}","releases_url":"https://api.github.com/repos/jrasanen/ping/releases{/id}","deployments_url":"https://api.github.com/repos/jrasanen/ping/deployments","created_at":"2016-06-22T16:31:26Z","updated_at":"2016-06-22T16:31:27Z","pushed_at":"2016-06-22T16:48:15Z","git_url":"git://github.com/jrasanen/ping.git","ssh_url":"git@github.com:jrasanen/ping.git","clone_url":"https://github.com/jrasanen/ping.git","svn_url":"https://github.com/jrasanen/ping","homepage":"","size":13,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"parkr:master","ref":"master","sha":"f868f18967a106167e2585a9f37a2aba0fd4c4fd","user":{"login":"parkr","id":237985,"avatar_url":"https://avatars.githubusercontent.com/u/237985?v=3","gravatar_id":"","url":"https://api.github.com/users/parkr","html_url":"https://github.com/parkr","followers_url":"https://api.github.com/users/parkr/followers","following_url":"https://api.github.com/users/parkr/following{/other_user}","gists_url":"https://api.github.com/users/parkr/gists{/gist_id}","starred_url":"https://api.github.com/users/parkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkr/subscriptions","organizations_url":"https://api.github.com/users/parkr/orgs","repos_url":"https://api.github.com/users/parkr/repos","events_url":"https://api.github.com/users/parkr/events{/privacy}","received_events_url":"https://api.github.com/users/parkr/received_events","type":"User","site_admin":true},"repo":{"id":28767325,"name":"ping","full_name":"parkr/ping","owner":{"login":"parkr","id":237985,"avatar_url":"https://avatars.githubusercontent.com/u/237985?v=3","gravatar_id":"","url":"https://api.github.com/users/parkr","html_url":"https://github.com/parkr","followers_url":"https://api.github.com/users/parkr/followers","following_url":"https://api.github.com/users/parkr/following{/other_user}","gists_url":"https://api.github.com/users/parkr/gists{/gist_id}","starred_url":"https://api.github.com/users/parkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parkr/subscriptions","organizations_url":"https://api.github.com/users/parkr/orgs","repos_url":"https://api.github.com/users/parkr/repos","events_url":"https://api.github.com/users/parkr/events{/privacy}","received_events_url":"https://api.github.com/users/parkr/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/parkr/ping","description":":bar_chart: Your very own Google Analytics replacement, without all of the Google. Simple as pie.","fork":false,"url":"https://api.github.com/repos/parkr/ping","forks_url":"https://api.github.com/repos/parkr/ping/forks","keys_url":"https://api.github.com/repos/parkr/ping/keys{/key_id}","collaborators_url":"https://api.github.com/repos/parkr/ping/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/parkr/ping/teams","hooks_url":"https://api.github.com/repos/parkr/ping/hooks","issue_events_url":"https://api.github.com/repos/parkr/ping/issues/events{/number}","events_url":"https://api.github.com/repos/parkr/ping/events","assignees_url":"https://api.github.com/repos/parkr/ping/assignees{/user}","branches_url":"https://api.github.com/repos/parkr/ping/branches{/branch}","tags_url":"https://api.github.com/repos/parkr/ping/tags","blobs_url":"https://api.github.com/repos/parkr/ping/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/parkr/ping/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/parkr/ping/git/refs{/sha}","trees_url":"https://api.github.com/repos/parkr/ping/git/trees{/sha}","statuses_url":"https://api.github.com/repos/parkr/ping/statuses/{sha}","languages_url":"https://api.github.com/repos/parkr/ping/languages","stargazers_url":"https://api.github.com/repos/parkr/ping/stargazers","contributors_url":"https://api.github.com/repos/parkr/ping/contributors","subscribers_url":"https://api.github.com/repos/parkr/ping/subscribers","subscription_url":"https://api.github.com/repos/parkr/ping/subscription","commits_url":"https://api.github.com/repos/parkr/ping/commits{/sha}","git_commits_url":"https://api.github.com/repos/parkr/ping/git/commits{/sha}","comments_url":"https://api.github.com/repos/parkr/ping/comments{/number}","issue_comment_url":"https://api.github.com/repos/parkr/ping/issues/comments{/number}","contents_url":"https://api.github.com/repos/parkr/ping/contents/{+path}","compare_url":"https://api.github.com/repos/parkr/ping/compare/{base}...{head}","merges_url":"https://api.github.com/repos/parkr/ping/merges","archive_url":"https://api.github.com/repos/parkr/ping/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/parkr/ping/downloads","issues_url":"https://api.github.com/repos/parkr/ping/issues{/number}","pulls_url":"https://api.github.com/repos/parkr/ping/pulls{/number}","milestones_url":"https://api.github.com/repos/parkr/ping/milestones{/number}","notifications_url":"https://api.github.com/repos/parkr/ping/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/parkr/ping/labels{/name}","releases_url":"https://api.github.com/repos/parkr/ping/releases{/id}","deployments_url":"https://api.github.com/repos/parkr/ping/deployments","created_at":"2015-01-04T07:16:28Z","updated_at":"2016-06-22T16:57:07Z","pushed_at":"2016-06-22T16:49:17Z","git_url":"git://github.com/parkr/ping.git","ssh_url":"git@github.com:parkr/ping.git","clone_url":"https://github.com/parkr/ping.git","svn_url":"https://github.com/parkr/ping","homepage":"","size":13,"stargazers_count":22,"watchers_count":22,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/parkr/ping/pulls/3"},"html":{"href":"https://github.com/parkr/ping/pull/3"},"issue":{"href":"https://api.github.com/repos/parkr/ping/issues/3"},"comments":{"href":"https://api.github.com/repos/parkr/ping/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/parkr/ping/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/parkr/ping/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/parkr/ping/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/parkr/ping/statuses/baaab09c44dd16cf7fb3964d91ce4d89cd275c15"}}}}
{"actor":{"display_login":"parkr"}}