{"action":"created","comment":{"url":"https://api.github.com/repos/sendgrid/rest/pulls/comments/83341865","pull_request_review_id":4192756,"id":83341865,"diff_hunk":"@@ -90,39 +51,39 @@ func BuildResponse(res *http.Response) (*Response, error) {\n }\n \n // API is the main interface to the API.\n-func API(request Request) (*Response, error) {\n+func API(request *http.Request) (*Response, error) {\n \treturn DefaultClient.API(request)\n }\n \n // The following functions enable the ability to define a\n // custom HTTP Client\n \n // MakeRequest makes the API call.\n-func (c *Client) MakeRequest(req *http.Request) (*http.Response, error) {\n+func (c *Client) makeRequest(req *http.Request) (*http.Response, error) {\n \treturn c.HTTPClient.Do(req)\n }\n \n // API is the main interface to the API.\n-func (c *Client) API(request Request) (*Response, error) {\n-\t// Add any query parameters to the URL.\n-\tif len(request.QueryParams) != 0 {\n-\t\trequest.BaseURL = AddQueryParameters(request.BaseURL, request.QueryParams)\n+func (c *Client) API(request *http.Request) (*Response, error) {\n+\tif request == nil {\n+\t\treturn nil, errors.New(\"invalid request: request cannot be nil\")\n \t}\n+\t_, supportedMethod := supportedMethods[request.Method]\n \n-\t// Build the HTTP request object.\n-\treq, err := BuildRequestObject(request)\n-\tif err != nil {\n-\t\treturn nil, err\n+\tif !supportedMethod {\n+\t\treturn nil, errors.New(\"unsupported request method:\" + request.Method)\n+\t}\n+\n+\tif request.Header.Get(\"Content-Type\") == \"\" && request.Body != nil {\n+\t\trequest.Header.Set(\"Content-Type\", \"application/json\")\n \t}","path":"rest.go","position":132,"original_position":132,"commit_id":"b5bc2398b8dedadeff94fdd73f04dd09653e4062","original_commit_id":"b5bc2398b8dedadeff94fdd73f04dd09653e4062","user":{"login":"willmadison","id":1326766,"avatar_url":"https://avatars.githubusercontent.com/u/1326766?v=3","gravatar_id":"","url":"https://api.github.com/users/willmadison","html_url":"https://github.com/willmadison","followers_url":"https://api.github.com/users/willmadison/followers","following_url":"https://api.github.com/users/willmadison/following{/other_user}","gists_url":"https://api.github.com/users/willmadison/gists{/gist_id}","starred_url":"https://api.github.com/users/willmadison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willmadison/subscriptions","organizations_url":"https://api.github.com/users/willmadison/orgs","repos_url":"https://api.github.com/users/willmadison/repos","events_url":"https://api.github.com/users/willmadison/events{/privacy}","received_events_url":"https://api.github.com/users/willmadison/received_events","type":"User","site_admin":false},"body":"request is actually of type http.Request so there's no control over the type of request.Body as it's a builtin. I only added this handling because there was an existing use case where content type is supposed to default to application/json if it's not set and there is a request body.","created_at":"2016-10-14T00:43:57Z","updated_at":"2016-10-14T00:43:57Z","html_url":"https://github.com/sendgrid/rest/pull/12#discussion_r83341865","pull_request_url":"https://api.github.com/repos/sendgrid/rest/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/sendgrid/rest/pulls/comments/83341865"},"html":{"href":"https://github.com/sendgrid/rest/pull/12#discussion_r83341865"},"pull_request":{"href":"https://api.github.com/repos/sendgrid/rest/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/sendgrid/rest/pulls/12","id":88579075,"html_url":"https://github.com/sendgrid/rest/pull/12","diff_url":"https://github.com/sendgrid/rest/pull/12.diff","patch_url":"https://github.com/sendgrid/rest/pull/12.patch","issue_url":"https://api.github.com/repos/sendgrid/rest/issues/12","number":12,"state":"open","locked":false,"title":"Addresses #3. Updated to use Go's http.Request/Response idioms","user":{"login":"willmadison","id":1326766,"avatar_url":"https://avatars.githubusercontent.com/u/1326766?v=3","gravatar_id":"","url":"https://api.github.com/users/willmadison","html_url":"https://github.com/willmadison","followers_url":"https://api.github.com/users/willmadison/followers","following_url":"https://api.github.com/users/willmadison/following{/other_user}","gists_url":"https://api.github.com/users/willmadison/gists{/gist_id}","starred_url":"https://api.github.com/users/willmadison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willmadison/subscriptions","organizations_url":"https://api.github.com/users/willmadison/orgs","repos_url":"https://api.github.com/users/willmadison/repos","events_url":"https://api.github.com/users/willmadison/events{/privacy}","received_events_url":"https://api.github.com/users/willmadison/received_events","type":"User","site_admin":false},"body":"Also updated example usage in the README.","created_at":"2016-10-09T12:19:55Z","updated_at":"2016-10-14T00:43:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aed22226152d88afc224d837b2f6fc2ff28aa494","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sendgrid/rest/pulls/12/commits","review_comments_url":"https://api.github.com/repos/sendgrid/rest/pulls/12/comments","review_comment_url":"https://api.github.com/repos/sendgrid/rest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sendgrid/rest/issues/12/comments","statuses_url":"https://api.github.com/repos/sendgrid/rest/statuses/b5bc2398b8dedadeff94fdd73f04dd09653e4062","head":{"label":"willmadison:master","ref":"master","sha":"b5bc2398b8dedadeff94fdd73f04dd09653e4062","user":{"login":"willmadison","id":1326766,"avatar_url":"https://avatars.githubusercontent.com/u/1326766?v=3","gravatar_id":"","url":"https://api.github.com/users/willmadison","html_url":"https://github.com/willmadison","followers_url":"https://api.github.com/users/willmadison/followers","following_url":"https://api.github.com/users/willmadison/following{/other_user}","gists_url":"https://api.github.com/users/willmadison/gists{/gist_id}","starred_url":"https://api.github.com/users/willmadison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willmadison/subscriptions","organizations_url":"https://api.github.com/users/willmadison/orgs","repos_url":"https://api.github.com/users/willmadison/repos","events_url":"https://api.github.com/users/willmadison/events{/privacy}","received_events_url":"https://api.github.com/users/willmadison/received_events","type":"User","site_admin":false},"repo":{"id":70397178,"name":"rest","full_name":"willmadison/rest","owner":{"login":"willmadison","id":1326766,"avatar_url":"https://avatars.githubusercontent.com/u/1326766?v=3","gravatar_id":"","url":"https://api.github.com/users/willmadison","html_url":"https://github.com/willmadison","followers_url":"https://api.github.com/users/willmadison/followers","following_url":"https://api.github.com/users/willmadison/following{/other_user}","gists_url":"https://api.github.com/users/willmadison/gists{/gist_id}","starred_url":"https://api.github.com/users/willmadison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willmadison/subscriptions","organizations_url":"https://api.github.com/users/willmadison/orgs","repos_url":"https://api.github.com/users/willmadison/repos","events_url":"https://api.github.com/users/willmadison/events{/privacy}","received_events_url":"https://api.github.com/users/willmadison/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/willmadison/rest","description":"HTTP client for RESTful APIs, simplified for Go","fork":true,"url":"https://api.github.com/repos/willmadison/rest","forks_url":"https://api.github.com/repos/willmadison/rest/forks","keys_url":"https://api.github.com/repos/willmadison/rest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/willmadison/rest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/willmadison/rest/teams","hooks_url":"https://api.github.com/repos/willmadison/rest/hooks","issue_events_url":"https://api.github.com/repos/willmadison/rest/issues/events{/number}","events_url":"https://api.github.com/repos/willmadison/rest/events","assignees_url":"https://api.github.com/repos/willmadison/rest/assignees{/user}","branches_url":"https://api.github.com/repos/willmadison/rest/branches{/branch}","tags_url":"https://api.github.com/repos/willmadison/rest/tags","blobs_url":"https://api.github.com/repos/willmadison/rest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/willmadison/rest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/willmadison/rest/git/refs{/sha}","trees_url":"https://api.github.com/repos/willmadison/rest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/willmadison/rest/statuses/{sha}","languages_url":"https://api.github.com/repos/willmadison/rest/languages","stargazers_url":"https://api.github.com/repos/willmadison/rest/stargazers","contributors_url":"https://api.github.com/repos/willmadison/rest/contributors","subscribers_url":"https://api.github.com/repos/willmadison/rest/subscribers","subscription_url":"https://api.github.com/repos/willmadison/rest/subscription","commits_url":"https://api.github.com/repos/willmadison/rest/commits{/sha}","git_commits_url":"https://api.github.com/repos/willmadison/rest/git/commits{/sha}","comments_url":"https://api.github.com/repos/willmadison/rest/comments{/number}","issue_comment_url":"https://api.github.com/repos/willmadison/rest/issues/comments{/number}","contents_url":"https://api.github.com/repos/willmadison/rest/contents/{+path}","compare_url":"https://api.github.com/repos/willmadison/rest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/willmadison/rest/merges","archive_url":"https://api.github.com/repos/willmadison/rest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/willmadison/rest/downloads","issues_url":"https://api.github.com/repos/willmadison/rest/issues{/number}","pulls_url":"https://api.github.com/repos/willmadison/rest/pulls{/number}","milestones_url":"https://api.github.com/repos/willmadison/rest/milestones{/number}","notifications_url":"https://api.github.com/repos/willmadison/rest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/willmadison/rest/labels{/name}","releases_url":"https://api.github.com/repos/willmadison/rest/releases{/id}","deployments_url":"https://api.github.com/repos/willmadison/rest/deployments","created_at":"2016-10-09T10:56:39Z","updated_at":"2016-10-09T10:56:41Z","pushed_at":"2016-10-09T12:16:19Z","git_url":"git://github.com/willmadison/rest.git","ssh_url":"git@github.com:willmadison/rest.git","clone_url":"https://github.com/willmadison/rest.git","svn_url":"https://github.com/willmadison/rest","homepage":"","size":39,"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":"sendgrid:master","ref":"master","sha":"eeb63332169983f0b17c0f6a2e99f5c9ee094bcc","user":{"login":"sendgrid","id":181234,"avatar_url":"https://avatars.githubusercontent.com/u/181234?v=3","gravatar_id":"","url":"https://api.github.com/users/sendgrid","html_url":"https://github.com/sendgrid","followers_url":"https://api.github.com/users/sendgrid/followers","following_url":"https://api.github.com/users/sendgrid/following{/other_user}","gists_url":"https://api.github.com/users/sendgrid/gists{/gist_id}","starred_url":"https://api.github.com/users/sendgrid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sendgrid/subscriptions","organizations_url":"https://api.github.com/users/sendgrid/orgs","repos_url":"https://api.github.com/users/sendgrid/repos","events_url":"https://api.github.com/users/sendgrid/events{/privacy}","received_events_url":"https://api.github.com/users/sendgrid/received_events","type":"Organization","site_admin":false},"repo":{"id":54674815,"name":"rest","full_name":"sendgrid/rest","owner":{"login":"sendgrid","id":181234,"avatar_url":"https://avatars.githubusercontent.com/u/181234?v=3","gravatar_id":"","url":"https://api.github.com/users/sendgrid","html_url":"https://github.com/sendgrid","followers_url":"https://api.github.com/users/sendgrid/followers","following_url":"https://api.github.com/users/sendgrid/following{/other_user}","gists_url":"https://api.github.com/users/sendgrid/gists{/gist_id}","starred_url":"https://api.github.com/users/sendgrid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sendgrid/subscriptions","organizations_url":"https://api.github.com/users/sendgrid/orgs","repos_url":"https://api.github.com/users/sendgrid/repos","events_url":"https://api.github.com/users/sendgrid/events{/privacy}","received_events_url":"https://api.github.com/users/sendgrid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sendgrid/rest","description":"HTTP client for RESTful APIs, simplified for Go","fork":false,"url":"https://api.github.com/repos/sendgrid/rest","forks_url":"https://api.github.com/repos/sendgrid/rest/forks","keys_url":"https://api.github.com/repos/sendgrid/rest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sendgrid/rest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sendgrid/rest/teams","hooks_url":"https://api.github.com/repos/sendgrid/rest/hooks","issue_events_url":"https://api.github.com/repos/sendgrid/rest/issues/events{/number}","events_url":"https://api.github.com/repos/sendgrid/rest/events","assignees_url":"https://api.github.com/repos/sendgrid/rest/assignees{/user}","branches_url":"https://api.github.com/repos/sendgrid/rest/branches{/branch}","tags_url":"https://api.github.com/repos/sendgrid/rest/tags","blobs_url":"https://api.github.com/repos/sendgrid/rest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sendgrid/rest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sendgrid/rest/git/refs{/sha}","trees_url":"https://api.github.com/repos/sendgrid/rest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sendgrid/rest/statuses/{sha}","languages_url":"https://api.github.com/repos/sendgrid/rest/languages","stargazers_url":"https://api.github.com/repos/sendgrid/rest/stargazers","contributors_url":"https://api.github.com/repos/sendgrid/rest/contributors","subscribers_url":"https://api.github.com/repos/sendgrid/rest/subscribers","subscription_url":"https://api.github.com/repos/sendgrid/rest/subscription","commits_url":"https://api.github.com/repos/sendgrid/rest/commits{/sha}","git_commits_url":"https://api.github.com/repos/sendgrid/rest/git/commits{/sha}","comments_url":"https://api.github.com/repos/sendgrid/rest/comments{/number}","issue_comment_url":"https://api.github.com/repos/sendgrid/rest/issues/comments{/number}","contents_url":"https://api.github.com/repos/sendgrid/rest/contents/{+path}","compare_url":"https://api.github.com/repos/sendgrid/rest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sendgrid/rest/merges","archive_url":"https://api.github.com/repos/sendgrid/rest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sendgrid/rest/downloads","issues_url":"https://api.github.com/repos/sendgrid/rest/issues{/number}","pulls_url":"https://api.github.com/repos/sendgrid/rest/pulls{/number}","milestones_url":"https://api.github.com/repos/sendgrid/rest/milestones{/number}","notifications_url":"https://api.github.com/repos/sendgrid/rest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sendgrid/rest/labels{/name}","releases_url":"https://api.github.com/repos/sendgrid/rest/releases{/id}","deployments_url":"https://api.github.com/repos/sendgrid/rest/deployments","created_at":"2016-03-24T21:17:00Z","updated_at":"2016-09-21T09:45:17Z","pushed_at":"2016-10-13T23:44:59Z","git_url":"git://github.com/sendgrid/rest.git","ssh_url":"git@github.com:sendgrid/rest.git","clone_url":"https://github.com/sendgrid/rest.git","svn_url":"https://github.com/sendgrid/rest","homepage":"","size":41,"stargazers_count":12,"watchers_count":12,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":8,"forks":13,"open_issues":8,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sendgrid/rest/pulls/12"},"html":{"href":"https://github.com/sendgrid/rest/pull/12"},"issue":{"href":"https://api.github.com/repos/sendgrid/rest/issues/12"},"comments":{"href":"https://api.github.com/repos/sendgrid/rest/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/sendgrid/rest/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/sendgrid/rest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sendgrid/rest/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/sendgrid/rest/statuses/b5bc2398b8dedadeff94fdd73f04dd09653e4062"}}}}
{"actor":{"display_login":"willmadison"}}