GitHub PullRequestReviewCommentEvent at 2014-08-05 20:30:59
Repository: metron
Actor: umbrae
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/ajacksified/metron/pulls/comments/15839499","id":15839499,"diff_hunk":"@@ -0,0 +1,143 @@\n+/* jshint strict:false */\n+\n+var http = require('http');\n+var url = require('url');\n+var qs = require('querystring');\n+var utils = require('./utils');\n+var Parameter = require('./parameter');\n+\n+var defaultConfig = {\n+  segments: [],\n+  port: 8000\n+};\n+\n+function Metron(config) {\n+  this.config = utils.merge(defaultConfig, config);\n+}\n+\n+Metron.prototype.get = function(key) {\n+  return this.config[key];\n+}\n+\n+Metron.prototype.set = function(obj) {\n+  this.config = utils.merge(this.config, obj);\n+  return this.config;\n+}\n+\n+Metron.prototype.start = function() {\n+  var server  = http.createServer(this.processRequest.bind(this));\n+  this.server = server;\n+\n+  server.listen(this.get('port'));\n+}\n+\n+Metron.prototype.stop = function() {\n+  this.server.close();\n+}\n+\n+Metron.prototype.processRequest = function(req, res) {\n+  var params = { };\n+  var parsedUrl = url.parse(req.url, true);\n+\n+  if (req.method === 'GET') {\n+    if (!parsedUrl.query || !parsedUrl.query.data) {\n+      return this.endRequest(req, res, 400, 'No data passed in.');\n+    }\n+\n+    try{\n+      req.params = JSON.parse(parsedUrl.query.data);\n+      this.processParameters(req, res);\n+    }catch(e) {\n+      return this.endRequest(req, res, 400, e);\n+    }\n+  } else{\n+    var body = [];\n+\n+    req.on('data', function (data) {\n+      body.push(data.toString());\n+    });\n+\n+    req.on('end', function () {\n+      body = body.join('');\n+\n+      if (req.headers['Content-Type'].toLowerCase().indexOf('json') > -1) {\n+        try{\n+          params = JSON.parse(body);\n+        }catch(e) {\n+          return this.endRequest(req, res, 400, e);\n+        }\n+      } else{\n+        req.params = qs.parse(body);\n+        this.processParameters(req, res);\n+      }\n+    });\n+  }\n+}\n+\n+Metron.prototype.endRequest = function(req, res, statusCode, error) {\n+  if (error && this.config.debug) {\n+    console.log('ERROR:');\n+    console.log(req.params);\n+    console.log(error);\n+  }\n+\n+  req.ended = true;\n+  res.writeHead(statusCode || 204);\n+  res.write(error);\n+  res.end();\n+};\n+\n+Metron.prototype.processParameters = function(req, res) {\n+  var params = req.params;\n+\n+  if (this.config.middleware) {\n+    for (var i = 0; i < this.config.middleware.length; i++) {\n+      this.config.middleware[i](req, res, this);\n+      // return early if one of the middlewares ended the request.\n+      if (req.ended) return;\n+    }\n+  }\n+\n+  for (var segmentName in params) {","path":"src/metron.js","position":101,"original_position":101,"commit_id":"94f815aaa029d2c4a45fb9656cd7df72827b8d55","original_commit_id":"94f815aaa029d2c4a45fb9656cd7df72827b8d55","user":{"login":"umbrae","id":285920,"avatar_url":"https://avatars.githubusercontent.com/u/285920?v=2","gravatar_id":"76a944e55ba3103579f9a3e85f775389","url":"https://api.github.com/users/umbrae","html_url":"https://github.com/umbrae","followers_url":"https://api.github.com/users/umbrae/followers","following_url":"https://api.github.com/users/umbrae/following{/other_user}","gists_url":"https://api.github.com/users/umbrae/gists{/gist_id}","starred_url":"https://api.github.com/users/umbrae/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umbrae/subscriptions","organizations_url":"https://api.github.com/users/umbrae/orgs","repos_url":"https://api.github.com/users/umbrae/repos","events_url":"https://api.github.com/users/umbrae/events{/privacy}","received_events_url":"https://api.github.com/users/umbrae/received_events","type":"User","site_admin":false},"body":"Do we need a `hasOwnProperty` guard? I honestly don't know.","created_at":"2014-08-05T20:30:59Z","updated_at":"2014-08-05T20:30:59Z","html_url":"https://github.com/ajacksified/metron/pull/1#discussion_r15839499","pull_request_url":"https://api.github.com/repos/ajacksified/metron/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ajacksified/metron/pulls/comments/15839499"},"html":{"href":"https://github.com/ajacksified/metron/pull/1#discussion_r15839499"},"pull_request":{"href":"https://api.github.com/repos/ajacksified/metron/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ajacksified/metron/pulls/1","id":19296399,"html_url":"https://github.com/ajacksified/metron/pull/1","diff_url":"https://github.com/ajacksified/metron/pull/1.diff","patch_url":"https://github.com/ajacksified/metron/pull/1.patch","issue_url":"https://api.github.com/repos/ajacksified/metron/issues/1","number":1,"state":"open","title":"Metron","user":{"login":"ajacksified","id":175515,"avatar_url":"https://avatars.githubusercontent.com/u/175515?v=2","gravatar_id":"a29db26f9fdc4d5a689d894507c84edc","url":"https://api.github.com/users/ajacksified","html_url":"https://github.com/ajacksified","followers_url":"https://api.github.com/users/ajacksified/followers","following_url":"https://api.github.com/users/ajacksified/following{/other_user}","gists_url":"https://api.github.com/users/ajacksified/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacksified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacksified/subscriptions","organizations_url":"https://api.github.com/users/ajacksified/orgs","repos_url":"https://api.github.com/users/ajacksified/repos","events_url":"https://api.github.com/users/ajacksified/events{/privacy}","received_events_url":"https://api.github.com/users/ajacksified/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-08-04T17:46:50Z","updated_at":"2014-08-05T20:30:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e2f0bbf8f552e867a312f5792f8afa9a8d3cd8c3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ajacksified/metron/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ajacksified/metron/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ajacksified/metron/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ajacksified/metron/issues/1/comments","statuses_url":"https://api.github.com/repos/ajacksified/metron/statuses/94f815aaa029d2c4a45fb9656cd7df72827b8d55","head":{"label":"ajacksified:metron","ref":"metron","sha":"94f815aaa029d2c4a45fb9656cd7df72827b8d55","user":{"login":"ajacksified","id":175515,"avatar_url":"https://avatars.githubusercontent.com/u/175515?v=2","gravatar_id":"a29db26f9fdc4d5a689d894507c84edc","url":"https://api.github.com/users/ajacksified","html_url":"https://github.com/ajacksified","followers_url":"https://api.github.com/users/ajacksified/followers","following_url":"https://api.github.com/users/ajacksified/following{/other_user}","gists_url":"https://api.github.com/users/ajacksified/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacksified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacksified/subscriptions","organizations_url":"https://api.github.com/users/ajacksified/orgs","repos_url":"https://api.github.com/users/ajacksified/repos","events_url":"https://api.github.com/users/ajacksified/events{/privacy}","received_events_url":"https://api.github.com/users/ajacksified/received_events","type":"User","site_admin":false},"repo":{"id":21441055,"name":"metron","full_name":"ajacksified/metron","owner":{"login":"ajacksified","id":175515,"avatar_url":"https://avatars.githubusercontent.com/u/175515?v=2","gravatar_id":"a29db26f9fdc4d5a689d894507c84edc","url":"https://api.github.com/users/ajacksified","html_url":"https://github.com/ajacksified","followers_url":"https://api.github.com/users/ajacksified/followers","following_url":"https://api.github.com/users/ajacksified/following{/other_user}","gists_url":"https://api.github.com/users/ajacksified/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacksified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacksified/subscriptions","organizations_url":"https://api.github.com/users/ajacksified/orgs","repos_url":"https://api.github.com/users/ajacksified/repos","events_url":"https://api.github.com/users/ajacksified/events{/privacy}","received_events_url":"https://api.github.com/users/ajacksified/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ajacksified/metron","description":"simple whitelisted statsd passthrough.","fork":false,"url":"https://api.github.com/repos/ajacksified/metron","forks_url":"https://api.github.com/repos/ajacksified/metron/forks","keys_url":"https://api.github.com/repos/ajacksified/metron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ajacksified/metron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ajacksified/metron/teams","hooks_url":"https://api.github.com/repos/ajacksified/metron/hooks","issue_events_url":"https://api.github.com/repos/ajacksified/metron/issues/events{/number}","events_url":"https://api.github.com/repos/ajacksified/metron/events","assignees_url":"https://api.github.com/repos/ajacksified/metron/assignees{/user}","branches_url":"https://api.github.com/repos/ajacksified/metron/branches{/branch}","tags_url":"https://api.github.com/repos/ajacksified/metron/tags","blobs_url":"https://api.github.com/repos/ajacksified/metron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ajacksified/metron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ajacksified/metron/git/refs{/sha}","trees_url":"https://api.github.com/repos/ajacksified/metron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ajacksified/metron/statuses/{sha}","languages_url":"https://api.github.com/repos/ajacksified/metron/languages","stargazers_url":"https://api.github.com/repos/ajacksified/metron/stargazers","contributors_url":"https://api.github.com/repos/ajacksified/metron/contributors","subscribers_url":"https://api.github.com/repos/ajacksified/metron/subscribers","subscription_url":"https://api.github.com/repos/ajacksified/metron/subscription","commits_url":"https://api.github.com/repos/ajacksified/metron/commits{/sha}","git_commits_url":"https://api.github.com/repos/ajacksified/metron/git/commits{/sha}","comments_url":"https://api.github.com/repos/ajacksified/metron/comments{/number}","issue_comment_url":"https://api.github.com/repos/ajacksified/metron/issues/comments/{number}","contents_url":"https://api.github.com/repos/ajacksified/metron/contents/{+path}","compare_url":"https://api.github.com/repos/ajacksified/metron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ajacksified/metron/merges","archive_url":"https://api.github.com/repos/ajacksified/metron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ajacksified/metron/downloads","issues_url":"https://api.github.com/repos/ajacksified/metron/issues{/number}","pulls_url":"https://api.github.com/repos/ajacksified/metron/pulls{/number}","milestones_url":"https://api.github.com/repos/ajacksified/metron/milestones{/number}","notifications_url":"https://api.github.com/repos/ajacksified/metron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ajacksified/metron/labels{/name}","releases_url":"https://api.github.com/repos/ajacksified/metron/releases{/id}","created_at":"2014-07-02T21:29:51Z","updated_at":"2014-07-16T16:42:34Z","pushed_at":"2014-08-04T17:46:47Z","git_url":"git://github.com/ajacksified/metron.git","ssh_url":"git@github.com:ajacksified/metron.git","clone_url":"https://github.com/ajacksified/metron.git","svn_url":"https://github.com/ajacksified/metron","homepage":null,"size":360,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ajacksified:master","ref":"master","sha":"fc85ed9c2919f2d79b7b551baa06b7ad9b195252","user":{"login":"ajacksified","id":175515,"avatar_url":"https://avatars.githubusercontent.com/u/175515?v=2","gravatar_id":"a29db26f9fdc4d5a689d894507c84edc","url":"https://api.github.com/users/ajacksified","html_url":"https://github.com/ajacksified","followers_url":"https://api.github.com/users/ajacksified/followers","following_url":"https://api.github.com/users/ajacksified/following{/other_user}","gists_url":"https://api.github.com/users/ajacksified/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacksified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacksified/subscriptions","organizations_url":"https://api.github.com/users/ajacksified/orgs","repos_url":"https://api.github.com/users/ajacksified/repos","events_url":"https://api.github.com/users/ajacksified/events{/privacy}","received_events_url":"https://api.github.com/users/ajacksified/received_events","type":"User","site_admin":false},"repo":{"id":21441055,"name":"metron","full_name":"ajacksified/metron","owner":{"login":"ajacksified","id":175515,"avatar_url":"https://avatars.githubusercontent.com/u/175515?v=2","gravatar_id":"a29db26f9fdc4d5a689d894507c84edc","url":"https://api.github.com/users/ajacksified","html_url":"https://github.com/ajacksified","followers_url":"https://api.github.com/users/ajacksified/followers","following_url":"https://api.github.com/users/ajacksified/following{/other_user}","gists_url":"https://api.github.com/users/ajacksified/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacksified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacksified/subscriptions","organizations_url":"https://api.github.com/users/ajacksified/orgs","repos_url":"https://api.github.com/users/ajacksified/repos","events_url":"https://api.github.com/users/ajacksified/events{/privacy}","received_events_url":"https://api.github.com/users/ajacksified/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ajacksified/metron","description":"simple whitelisted statsd passthrough.","fork":false,"url":"https://api.github.com/repos/ajacksified/metron","forks_url":"https://api.github.com/repos/ajacksified/metron/forks","keys_url":"https://api.github.com/repos/ajacksified/metron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ajacksified/metron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ajacksified/metron/teams","hooks_url":"https://api.github.com/repos/ajacksified/metron/hooks","issue_events_url":"https://api.github.com/repos/ajacksified/metron/issues/events{/number}","events_url":"https://api.github.com/repos/ajacksified/metron/events","assignees_url":"https://api.github.com/repos/ajacksified/metron/assignees{/user}","branches_url":"https://api.github.com/repos/ajacksified/metron/branches{/branch}","tags_url":"https://api.github.com/repos/ajacksified/metron/tags","blobs_url":"https://api.github.com/repos/ajacksified/metron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ajacksified/metron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ajacksified/metron/git/refs{/sha}","trees_url":"https://api.github.com/repos/ajacksified/metron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ajacksified/metron/statuses/{sha}","languages_url":"https://api.github.com/repos/ajacksified/metron/languages","stargazers_url":"https://api.github.com/repos/ajacksified/metron/stargazers","contributors_url":"https://api.github.com/repos/ajacksified/metron/contributors","subscribers_url":"https://api.github.com/repos/ajacksified/metron/subscribers","subscription_url":"https://api.github.com/repos/ajacksified/metron/subscription","commits_url":"https://api.github.com/repos/ajacksified/metron/commits{/sha}","git_commits_url":"https://api.github.com/repos/ajacksified/metron/git/commits{/sha}","comments_url":"https://api.github.com/repos/ajacksified/metron/comments{/number}","issue_comment_url":"https://api.github.com/repos/ajacksified/metron/issues/comments/{number}","contents_url":"https://api.github.com/repos/ajacksified/metron/contents/{+path}","compare_url":"https://api.github.com/repos/ajacksified/metron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ajacksified/metron/merges","archive_url":"https://api.github.com/repos/ajacksified/metron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ajacksified/metron/downloads","issues_url":"https://api.github.com/repos/ajacksified/metron/issues{/number}","pulls_url":"https://api.github.com/repos/ajacksified/metron/pulls{/number}","milestones_url":"https://api.github.com/repos/ajacksified/metron/milestones{/number}","notifications_url":"https://api.github.com/repos/ajacksified/metron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ajacksified/metron/labels{/name}","releases_url":"https://api.github.com/repos/ajacksified/metron/releases{/id}","created_at":"2014-07-02T21:29:51Z","updated_at":"2014-07-16T16:42:34Z","pushed_at":"2014-08-04T17:46:47Z","git_url":"git://github.com/ajacksified/metron.git","ssh_url":"git@github.com:ajacksified/metron.git","clone_url":"https://github.com/ajacksified/metron.git","svn_url":"https://github.com/ajacksified/metron","homepage":null,"size":360,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"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/ajacksified/metron/pulls/1"},"html":{"href":"https://github.com/ajacksified/metron/pull/1"},"issue":{"href":"https://api.github.com/repos/ajacksified/metron/issues/1"},"comments":{"href":"https://api.github.com/repos/ajacksified/metron/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ajacksified/metron/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ajacksified/metron/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ajacksified/metron/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ajacksified/metron/statuses/94f815aaa029d2c4a45fb9656cd7df72827b8d55"}}}}