{"action":"closed","number":1260,"pull_request":{"url":"https://api.github.com/repos/strongloop/loopback-next/pulls/1260","id":181943060,"html_url":"https://github.com/strongloop/loopback-next/pull/1260","diff_url":"https://github.com/strongloop/loopback-next/pull/1260.diff","patch_url":"https://github.com/strongloop/loopback-next/pull/1260.patch","issue_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1260","number":1260,"state":"closed","locked":false,"title":"[don't merge]poc: customize statusCode using response spec","user":{"login":"jannyHou","id":12554153,"avatar_url":"https://avatars0.githubusercontent.com/u/12554153?v=4","gravatar_id":"","url":"https://api.github.com/users/jannyHou","html_url":"https://github.com/jannyHou","followers_url":"https://api.github.com/users/jannyHou/followers","following_url":"https://api.github.com/users/jannyHou/following{/other_user}","gists_url":"https://api.github.com/users/jannyHou/gists{/gist_id}","starred_url":"https://api.github.com/users/jannyHou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jannyHou/subscriptions","organizations_url":"https://api.github.com/users/jannyHou/orgs","repos_url":"https://api.github.com/users/jannyHou/repos","events_url":"https://api.github.com/users/jannyHou/events{/privacy}","received_events_url":"https://api.github.com/users/jannyHou/received_events","type":"User","site_admin":false},"body":"A PoC based on discussion in PR https://github.com/strongloop/loopback-next/pull/1245/files.\r\nI highly doubt this PoC is less hacky than https://github.com/strongloop/loopback-next/pull/1245/ ...\r\nWhile want to keep it open for a while to drive some discussion.\r\n\r\nHad a talk with @bajtos , he points out an important thing: When a response returns `201`, it also includes a header with the URI of created item. see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2\r\n\r\nHere is a summary of discussions I have seen within team:\r\n\r\n## Plan 1 - set `statusCode` in controller\r\n\r\nSee @bajtos 's proposal in https://github.com/strongloop/loopback-next/issues/788#issuecomment-381639062\r\n\r\nDiscussion from @raymondfeng @virkt25 in [comment](https://github.com/strongloop/loopback-next/pull/1245/files#diff-576584d72083bead0929c10dfc101b01R201)\r\n\r\nA advantage of this approach is the returned result contains `statusCode`, `header`, `body`...etc, everything.\r\n\r\nMy concern for it is would all methods return a `httpResponse` to be identified with `create`? \r\n\r\nThe handler can detect the type of returned result, which may allow us to handle a `httpResponse` result and `body` result differently. \r\n\r\n## Plan 2 - read `statusCode` from `response` spec\r\n\r\nThis PoC implements ^ in a simpler way. It adds a 3rd parameter in `send` provider to expose `route.spec` to the writer. While ideally we should bind route's spec to Context.\r\n\r\nFrom @bajtos \r\n> In general, I think we should eventually bind route's spec to Context, because I expect this to be useful in other places too.\r\n\r\nWhile this PR exposes a few problems for this approach:\r\nhttps://github.com/strongloop/loopback-next/pull/1260#issuecomment-381712236\r\n\r\n","created_at":"2018-04-16T17:57:44Z","updated_at":"2018-04-26T18:14:14Z","closed_at":"2018-04-26T18:14:14Z","merged_at":null,"merge_commit_sha":"7d4afbe11788c58eae52df3c1a49857a14744693","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":570635292,"url":"https://api.github.com/repos/strongloop/loopback-next/labels/review","name":"review","color":"eeeeee","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/strongloop/loopback-next/pulls/1260/commits","review_comments_url":"https://api.github.com/repos/strongloop/loopback-next/pulls/1260/comments","review_comment_url":"https://api.github.com/repos/strongloop/loopback-next/pulls/comments{/number}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1260/comments","statuses_url":"https://api.github.com/repos/strongloop/loopback-next/statuses/829faa04a43f07f6bf040986ebe5a7cf2a7e254d","head":{"label":"strongloop:poc/201-response","ref":"poc/201-response","sha":"829faa04a43f07f6bf040986ebe5a7cf2a7e254d","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":78452015,"name":"loopback-next","full_name":"strongloop/loopback-next","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback-next","description":"LoopBack makes it easy to build modern API applications that require complex integrations.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback-next","forks_url":"https://api.github.com/repos/strongloop/loopback-next/forks","keys_url":"https://api.github.com/repos/strongloop/loopback-next/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback-next/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback-next/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback-next/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback-next/events","assignees_url":"https://api.github.com/repos/strongloop/loopback-next/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback-next/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback-next/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback-next/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback-next/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback-next/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback-next/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback-next/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback-next/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback-next/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback-next/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback-next/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback-next/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback-next/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback-next/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback-next/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback-next/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback-next/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback-next/merges","archive_url":"https://api.github.com/repos/strongloop/loopback-next/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback-next/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback-next/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback-next/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback-next/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback-next/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback-next/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback-next/releases{/id}","deployments_url":"https://api.github.com/repos/strongloop/loopback-next/deployments","created_at":"2017-01-09T17:27:14Z","updated_at":"2018-04-26T15:42:43Z","pushed_at":"2018-04-26T18:06:16Z","git_url":"git://github.com/strongloop/loopback-next.git","ssh_url":"git@github.com:strongloop/loopback-next.git","clone_url":"https://github.com/strongloop/loopback-next.git","svn_url":"https://github.com/strongloop/loopback-next","homepage":"http://loopback.io","size":6023,"stargazers_count":579,"watchers_count":579,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":224,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":56,"open_issues":224,"watchers":579,"default_branch":"master"}},"base":{"label":"strongloop:master","ref":"master","sha":"c0130a60db7002944c4c93a6e0a6fda5e0fc71a7","user":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":78452015,"name":"loopback-next","full_name":"strongloop/loopback-next","owner":{"login":"strongloop","id":3020012,"avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback-next","description":"LoopBack makes it easy to build modern API applications that require complex integrations.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback-next","forks_url":"https://api.github.com/repos/strongloop/loopback-next/forks","keys_url":"https://api.github.com/repos/strongloop/loopback-next/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback-next/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback-next/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback-next/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback-next/events","assignees_url":"https://api.github.com/repos/strongloop/loopback-next/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback-next/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback-next/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback-next/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback-next/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback-next/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback-next/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback-next/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback-next/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback-next/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback-next/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback-next/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback-next/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback-next/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback-next/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback-next/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback-next/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback-next/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback-next/merges","archive_url":"https://api.github.com/repos/strongloop/loopback-next/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback-next/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback-next/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback-next/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback-next/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback-next/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback-next/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback-next/releases{/id}","deployments_url":"https://api.github.com/repos/strongloop/loopback-next/deployments","created_at":"2017-01-09T17:27:14Z","updated_at":"2018-04-26T15:42:43Z","pushed_at":"2018-04-26T18:06:16Z","git_url":"git://github.com/strongloop/loopback-next.git","ssh_url":"git@github.com:strongloop/loopback-next.git","clone_url":"https://github.com/strongloop/loopback-next.git","svn_url":"https://github.com/strongloop/loopback-next","homepage":"http://loopback.io","size":6023,"stargazers_count":579,"watchers_count":579,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":224,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":56,"open_issues":224,"watchers":579,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/1260"},"html":{"href":"https://github.com/strongloop/loopback-next/pull/1260"},"issue":{"href":"https://api.github.com/repos/strongloop/loopback-next/issues/1260"},"comments":{"href":"https://api.github.com/repos/strongloop/loopback-next/issues/1260/comments"},"review_comments":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/1260/comments"},"review_comment":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/1260/commits"},"statuses":{"href":"https://api.github.com/repos/strongloop/loopback-next/statuses/829faa04a43f07f6bf040986ebe5a7cf2a7e254d"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":true,"rebaseable":true,"mergeable_state":"unstable","merged_by":null,"comments":6,"review_comments":8,"maintainer_can_modify":false,"commits":1,"additions":42,"deletions":2,"changed_files":5}}
{"actor":{"display_login":"jannyHou"}}