{"action":"created","comment":{"url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/comments/38784921","id":38784921,"diff_hunk":"@@ -2,6 +2,30 @@ var express = require('express');\n var request = require('request');\n var streamBuffers = require(\"stream-buffers\");\n \n+function getRequestedUrl( req ) {\n+  var url = req.headers['x-request-url'];\n+  if (!url) {\n+    return resp.status(500).send('URL must be provided in x-request-url header');\n+  }\n+  delete req.headers['x-request-url'];\n+  return url;\n+}\n+\n+function serializeHeaders( req ) {\n+  var array = [];\n+  Object.keys(req.headers).forEach( function( key ) {\n+    var value = req.headers[key];\n+    array.push( key + ': ' + value );\n+  });\n+  return array.join('\\n');\n+}\n+\n+function enrichResponseWithRequestHeaders( req, resp ) {\n+  var serializedHeaders = serializeHeaders( req );","path":"lib/routes/try.js","position":23,"original_position":23,"commit_id":"ab8340b4f0de8ff80268becd2874574340dde469","original_commit_id":"ab8340b4f0de8ff80268becd2874574340dde469","user":{"login":"cianclarke","id":512937,"avatar_url":"https://avatars.githubusercontent.com/u/512937?v=3","gravatar_id":"","url":"https://api.github.com/users/cianclarke","html_url":"https://github.com/cianclarke","followers_url":"https://api.github.com/users/cianclarke/followers","following_url":"https://api.github.com/users/cianclarke/following{/other_user}","gists_url":"https://api.github.com/users/cianclarke/gists{/gist_id}","starred_url":"https://api.github.com/users/cianclarke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cianclarke/subscriptions","organizations_url":"https://api.github.com/users/cianclarke/orgs","repos_url":"https://api.github.com/users/cianclarke/repos","events_url":"https://api.github.com/users/cianclarke/events{/privacy}","received_events_url":"https://api.github.com/users/cianclarke/received_events","type":"User","site_admin":false},"body":"I think it's so the client knows exactly what headers were sent with the `request` module, rather than those the browser sends (as we don't really want the browser's content type etc making it through). \r\n@lfryc a comment in the code here describing what it's doing might be good as i'm not 100% sure either","created_at":"2015-09-04T19:11:47Z","updated_at":"2015-09-04T19:11:47Z","html_url":"https://github.com/feedhenry-templates/fh-api-mapper/pull/6#discussion_r38784921","pull_request_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/comments/38784921"},"html":{"href":"https://github.com/feedhenry-templates/fh-api-mapper/pull/6#discussion_r38784921"},"pull_request":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6","id":43906290,"html_url":"https://github.com/feedhenry-templates/fh-api-mapper/pull/6","diff_url":"https://github.com/feedhenry-templates/fh-api-mapper/pull/6.diff","patch_url":"https://github.com/feedhenry-templates/fh-api-mapper/pull/6.patch","issue_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/issues/6","number":6,"state":"closed","locked":false,"title":"Add persistence support using a Mongoose model. Add mappings routes & unit tests.","user":{"login":"cianclarke","id":512937,"avatar_url":"https://avatars.githubusercontent.com/u/512937?v=3","gravatar_id":"","url":"https://api.github.com/users/cianclarke","html_url":"https://github.com/cianclarke","followers_url":"https://api.github.com/users/cianclarke/followers","following_url":"https://api.github.com/users/cianclarke/following{/other_user}","gists_url":"https://api.github.com/users/cianclarke/gists{/gist_id}","starred_url":"https://api.github.com/users/cianclarke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cianclarke/subscriptions","organizations_url":"https://api.github.com/users/cianclarke/orgs","repos_url":"https://api.github.com/users/cianclarke/repos","events_url":"https://api.github.com/users/cianclarke/events{/privacy}","received_events_url":"https://api.github.com/users/cianclarke/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-01T17:57:12Z","updated_at":"2015-09-04T19:11:47Z","closed_at":"2015-09-04T12:16:22Z","merged_at":null,"merge_commit_sha":"73b855a3f73655cd53a071224a33a93a61df61f5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6/commits","review_comments_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6/comments","review_comment_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/issues/6/comments","statuses_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/statuses/ab8340b4f0de8ff80268becd2874574340dde469","head":{"label":"cianclarke:FH-1912-persist","ref":"FH-1912-persist","sha":"ab8340b4f0de8ff80268becd2874574340dde469","user":{"login":"cianclarke","id":512937,"avatar_url":"https://avatars.githubusercontent.com/u/512937?v=3","gravatar_id":"","url":"https://api.github.com/users/cianclarke","html_url":"https://github.com/cianclarke","followers_url":"https://api.github.com/users/cianclarke/followers","following_url":"https://api.github.com/users/cianclarke/following{/other_user}","gists_url":"https://api.github.com/users/cianclarke/gists{/gist_id}","starred_url":"https://api.github.com/users/cianclarke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cianclarke/subscriptions","organizations_url":"https://api.github.com/users/cianclarke/orgs","repos_url":"https://api.github.com/users/cianclarke/repos","events_url":"https://api.github.com/users/cianclarke/events{/privacy}","received_events_url":"https://api.github.com/users/cianclarke/received_events","type":"User","site_admin":false},"repo":{"id":41050886,"name":"fh-api-mapper","full_name":"cianclarke/fh-api-mapper","owner":{"login":"cianclarke","id":512937,"avatar_url":"https://avatars.githubusercontent.com/u/512937?v=3","gravatar_id":"","url":"https://api.github.com/users/cianclarke","html_url":"https://github.com/cianclarke","followers_url":"https://api.github.com/users/cianclarke/followers","following_url":"https://api.github.com/users/cianclarke/following{/other_user}","gists_url":"https://api.github.com/users/cianclarke/gists{/gist_id}","starred_url":"https://api.github.com/users/cianclarke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cianclarke/subscriptions","organizations_url":"https://api.github.com/users/cianclarke/orgs","repos_url":"https://api.github.com/users/cianclarke/repos","events_url":"https://api.github.com/users/cianclarke/events{/privacy}","received_events_url":"https://api.github.com/users/cianclarke/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cianclarke/fh-api-mapper","description":"API Mapping Tool","fork":true,"url":"https://api.github.com/repos/cianclarke/fh-api-mapper","forks_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/forks","keys_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/teams","hooks_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/hooks","issue_events_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/issues/events{/number}","events_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/events","assignees_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/assignees{/user}","branches_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/branches{/branch}","tags_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/tags","blobs_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/git/refs{/sha}","trees_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/statuses/{sha}","languages_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/languages","stargazers_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/stargazers","contributors_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/contributors","subscribers_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/subscribers","subscription_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/subscription","commits_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/commits{/sha}","git_commits_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/git/commits{/sha}","comments_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/comments{/number}","issue_comment_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/issues/comments{/number}","contents_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/contents/{+path}","compare_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/merges","archive_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/downloads","issues_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/issues{/number}","pulls_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/pulls{/number}","milestones_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/milestones{/number}","notifications_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/labels{/name}","releases_url":"https://api.github.com/repos/cianclarke/fh-api-mapper/releases{/id}","created_at":"2015-08-19T17:59:03Z","updated_at":"2015-09-01T13:54:51Z","pushed_at":"2015-09-02T21:07:19Z","git_url":"git://github.com/cianclarke/fh-api-mapper.git","ssh_url":"git@github.com:cianclarke/fh-api-mapper.git","clone_url":"https://github.com/cianclarke/fh-api-mapper.git","svn_url":"https://github.com/cianclarke/fh-api-mapper","homepage":null,"size":281,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"feedhenry-templates:master","ref":"master","sha":"3997ef92b7a9a4d374978fe532134e2be1c5d351","user":{"login":"feedhenry-templates","id":7250163,"avatar_url":"https://avatars.githubusercontent.com/u/7250163?v=3","gravatar_id":"","url":"https://api.github.com/users/feedhenry-templates","html_url":"https://github.com/feedhenry-templates","followers_url":"https://api.github.com/users/feedhenry-templates/followers","following_url":"https://api.github.com/users/feedhenry-templates/following{/other_user}","gists_url":"https://api.github.com/users/feedhenry-templates/gists{/gist_id}","starred_url":"https://api.github.com/users/feedhenry-templates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feedhenry-templates/subscriptions","organizations_url":"https://api.github.com/users/feedhenry-templates/orgs","repos_url":"https://api.github.com/users/feedhenry-templates/repos","events_url":"https://api.github.com/users/feedhenry-templates/events{/privacy}","received_events_url":"https://api.github.com/users/feedhenry-templates/received_events","type":"Organization","site_admin":false},"repo":{"id":41050724,"name":"fh-api-mapper","full_name":"feedhenry-templates/fh-api-mapper","owner":{"login":"feedhenry-templates","id":7250163,"avatar_url":"https://avatars.githubusercontent.com/u/7250163?v=3","gravatar_id":"","url":"https://api.github.com/users/feedhenry-templates","html_url":"https://github.com/feedhenry-templates","followers_url":"https://api.github.com/users/feedhenry-templates/followers","following_url":"https://api.github.com/users/feedhenry-templates/following{/other_user}","gists_url":"https://api.github.com/users/feedhenry-templates/gists{/gist_id}","starred_url":"https://api.github.com/users/feedhenry-templates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feedhenry-templates/subscriptions","organizations_url":"https://api.github.com/users/feedhenry-templates/orgs","repos_url":"https://api.github.com/users/feedhenry-templates/repos","events_url":"https://api.github.com/users/feedhenry-templates/events{/privacy}","received_events_url":"https://api.github.com/users/feedhenry-templates/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/feedhenry-templates/fh-api-mapper","description":"API Mapping Tool","fork":false,"url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper","forks_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/forks","keys_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/teams","hooks_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/hooks","issue_events_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/issues/events{/number}","events_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/events","assignees_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/assignees{/user}","branches_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/branches{/branch}","tags_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/tags","blobs_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/git/refs{/sha}","trees_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/statuses/{sha}","languages_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/languages","stargazers_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/stargazers","contributors_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/contributors","subscribers_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/subscribers","subscription_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/subscription","commits_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/commits{/sha}","git_commits_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/git/commits{/sha}","comments_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/comments{/number}","issue_comment_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/issues/comments{/number}","contents_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/contents/{+path}","compare_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/merges","archive_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/downloads","issues_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/issues{/number}","pulls_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls{/number}","milestones_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/milestones{/number}","notifications_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/labels{/name}","releases_url":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/releases{/id}","created_at":"2015-08-19T17:56:22Z","updated_at":"2015-08-19T20:09:30Z","pushed_at":"2015-09-04T12:25:08Z","git_url":"git://github.com/feedhenry-templates/fh-api-mapper.git","ssh_url":"git@github.com:feedhenry-templates/fh-api-mapper.git","clone_url":"https://github.com/feedhenry-templates/fh-api-mapper.git","svn_url":"https://github.com/feedhenry-templates/fh-api-mapper","homepage":null,"size":395,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":4,"forks":2,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6"},"html":{"href":"https://github.com/feedhenry-templates/fh-api-mapper/pull/6"},"issue":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/issues/6"},"comments":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/feedhenry-templates/fh-api-mapper/statuses/ab8340b4f0de8ff80268becd2874574340dde469"}}}}