{"action":"created","comment":{"url":"https://api.github.com/repos/benbjohnson/wtf/pulls/comments/92365273","pull_request_review_id":12878020,"id":92365273,"diff_hunk":"@@ -0,0 +1,76 @@\n+package http\n+\n+import (\n+\t\"net\"\n+\t\"net/http\"\n+\t\"net/url\"\n+\n+\t\"github.com/benbjohnson/wtf\"\n+)\n+\n+// DefaultAddr is the default bind address.\n+const DefaultAddr = \":3000\"\n+\n+// Server represents an HTTP server.\n+type Server struct {\n+\tln net.Listener\n+\n+\t// Handler to serve.\n+\tHandler *Handler\n+\n+\t// Bind address to open.\n+\tAddr string\n+}\n+\n+// NewServer returns a new instance of Server.\n+func NewServer() *Server {\n+\treturn &Server{\n+\t\tAddr: DefaultAddr,\n+\t}\n+}\n+\n+// Open opens a socket and serves the HTTP server.\n+func (s *Server) Open() error {\n+\t// Open socket.\n+\tln, err := net.Listen(\"tcp\", s.Addr)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\ts.ln = ln\n+\n+\t// Start HTTP server.\n+\tgo func() { http.Serve(s.ln, s.Handler) }()\n+\n+\treturn nil\n+}\n+\n+// Close closes the socket.\n+func (s *Server) Close() error {\n+\tif s.ln != nil {\n+\t\ts.ln.Close()\n+\t}\n+\treturn nil\n+}\n+\n+// Port returns the port that the server is open on. Only valid after open.\n+func (s *Server) Port() int {\n+\treturn s.ln.Addr().(*net.TCPAddr).Port\n+}\n+\n+// Client represents a client to connect to the HTTP server.\n+type Client struct {\n+\tURL         url.URL\n+\tdialService DialService\n+}\n+\n+// NewClient returns a new instance of Client.\n+func NewClient() *Client {\n+\tc := &Client{}\n+\tc.dialService.URL = &c.URL\n+\treturn c\n+}","path":"http/server.go","position":71,"original_position":71,"commit_id":"6d855c355488361b22b1a5ba13d9453e39141292","original_commit_id":"6d855c355488361b22b1a5ba13d9453e39141292","user":{"login":"billbell73","id":5602191,"avatar_url":"https://avatars.githubusercontent.com/u/5602191?v=3","gravatar_id":"","url":"https://api.github.com/users/billbell73","html_url":"https://github.com/billbell73","followers_url":"https://api.github.com/users/billbell73/followers","following_url":"https://api.github.com/users/billbell73/following{/other_user}","gists_url":"https://api.github.com/users/billbell73/gists{/gist_id}","starred_url":"https://api.github.com/users/billbell73/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billbell73/subscriptions","organizations_url":"https://api.github.com/users/billbell73/orgs","repos_url":"https://api.github.com/users/billbell73/repos","events_url":"https://api.github.com/users/billbell73/events{/privacy}","received_events_url":"https://api.github.com/users/billbell73/received_events","type":"User","site_admin":false},"body":"Thanks for your reply. I really appreciate your humouring my crazy example.  :)\r\n\r\nBut at the same time as my use case being eccentric, all I am really asking is how you would use the layout/structure you recommend for an app that receives a request, and then has to make an external http request before storing some data. (I was sorta guessing it was easier to talk about concrete examples in this kind of conversation/exchange; otherwise everything can get a bit abstract and people can start talking at cross purposes).\r\n\r\nSo at the risk of trying your patience: if in addition to the weather-adjusted stuff you wanted to retain endpoints that enabled you to save non-weather-adjusted data too, you would potentially have different handlers, a standard `DialHandler` with has a `bolt.DialService` as its DialService and a weather-adjusted `DialHandler` which has a `weatheradjusted.DialService` as its DialService. \r\n\r\nThe downside to this seems to me that your `handlePatchDial` function in both handlers would basically be identical. So I guess you would have a different approach?\r\n\r\nAlso how would you play it if you wanted to retain both functionality options within the same endpoint; i.e. on passing some parameter you can either weather-adjust the data or store directly?\r\n\r\nThanks very much again…","created_at":"2016-12-14T10:34:31Z","updated_at":"2016-12-14T10:34:31Z","html_url":"https://github.com/benbjohnson/wtf/pull/8#discussion_r92365273","pull_request_url":"https://api.github.com/repos/benbjohnson/wtf/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/benbjohnson/wtf/pulls/comments/92365273"},"html":{"href":"https://github.com/benbjohnson/wtf/pull/8#discussion_r92365273"},"pull_request":{"href":"https://api.github.com/repos/benbjohnson/wtf/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/benbjohnson/wtf/pulls/8","id":88467432,"html_url":"https://github.com/benbjohnson/wtf/pull/8","diff_url":"https://github.com/benbjohnson/wtf/pull/8.diff","patch_url":"https://github.com/benbjohnson/wtf/pull/8.patch","issue_url":"https://api.github.com/repos/benbjohnson/wtf/issues/8","number":8,"state":"open","locked":false,"title":"Add HTTP API.","user":{"login":"benbjohnson","id":118015,"avatar_url":"https://avatars.githubusercontent.com/u/118015?v=3","gravatar_id":"","url":"https://api.github.com/users/benbjohnson","html_url":"https://github.com/benbjohnson","followers_url":"https://api.github.com/users/benbjohnson/followers","following_url":"https://api.github.com/users/benbjohnson/following{/other_user}","gists_url":"https://api.github.com/users/benbjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/benbjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbjohnson/subscriptions","organizations_url":"https://api.github.com/users/benbjohnson/orgs","repos_url":"https://api.github.com/users/benbjohnson/repos","events_url":"https://api.github.com/users/benbjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/benbjohnson/received_events","type":"User","site_admin":false},"body":"## Overview\n\nAdds an `http` package containing a `Server` and `Client` which provide an HTTP API. The `Client` implements `wtf.Client`.\n\nHere is the related Medium post explaining the pull request: https://medium.com/@benbjohnson/wtf-dial-http-api-d8800ccd605f\n","created_at":"2016-10-07T16:19:27Z","updated_at":"2016-12-14T10:34:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8d3badfc20b75170b569ebfb8ebc40cdad40a6a5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/benbjohnson/wtf/pulls/8/commits","review_comments_url":"https://api.github.com/repos/benbjohnson/wtf/pulls/8/comments","review_comment_url":"https://api.github.com/repos/benbjohnson/wtf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/benbjohnson/wtf/issues/8/comments","statuses_url":"https://api.github.com/repos/benbjohnson/wtf/statuses/6d855c355488361b22b1a5ba13d9453e39141292","head":{"label":"benbjohnson:http","ref":"http","sha":"6d855c355488361b22b1a5ba13d9453e39141292","user":{"login":"benbjohnson","id":118015,"avatar_url":"https://avatars.githubusercontent.com/u/118015?v=3","gravatar_id":"","url":"https://api.github.com/users/benbjohnson","html_url":"https://github.com/benbjohnson","followers_url":"https://api.github.com/users/benbjohnson/followers","following_url":"https://api.github.com/users/benbjohnson/following{/other_user}","gists_url":"https://api.github.com/users/benbjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/benbjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbjohnson/subscriptions","organizations_url":"https://api.github.com/users/benbjohnson/orgs","repos_url":"https://api.github.com/users/benbjohnson/repos","events_url":"https://api.github.com/users/benbjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/benbjohnson/received_events","type":"User","site_admin":false},"repo":{"id":65945013,"name":"wtf","full_name":"benbjohnson/wtf","owner":{"login":"benbjohnson","id":118015,"avatar_url":"https://avatars.githubusercontent.com/u/118015?v=3","gravatar_id":"","url":"https://api.github.com/users/benbjohnson","html_url":"https://github.com/benbjohnson","followers_url":"https://api.github.com/users/benbjohnson/followers","following_url":"https://api.github.com/users/benbjohnson/following{/other_user}","gists_url":"https://api.github.com/users/benbjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/benbjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbjohnson/subscriptions","organizations_url":"https://api.github.com/users/benbjohnson/orgs","repos_url":"https://api.github.com/users/benbjohnson/repos","events_url":"https://api.github.com/users/benbjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/benbjohnson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benbjohnson/wtf","description":"Real-time WTF status","fork":false,"url":"https://api.github.com/repos/benbjohnson/wtf","forks_url":"https://api.github.com/repos/benbjohnson/wtf/forks","keys_url":"https://api.github.com/repos/benbjohnson/wtf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benbjohnson/wtf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benbjohnson/wtf/teams","hooks_url":"https://api.github.com/repos/benbjohnson/wtf/hooks","issue_events_url":"https://api.github.com/repos/benbjohnson/wtf/issues/events{/number}","events_url":"https://api.github.com/repos/benbjohnson/wtf/events","assignees_url":"https://api.github.com/repos/benbjohnson/wtf/assignees{/user}","branches_url":"https://api.github.com/repos/benbjohnson/wtf/branches{/branch}","tags_url":"https://api.github.com/repos/benbjohnson/wtf/tags","blobs_url":"https://api.github.com/repos/benbjohnson/wtf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benbjohnson/wtf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benbjohnson/wtf/git/refs{/sha}","trees_url":"https://api.github.com/repos/benbjohnson/wtf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benbjohnson/wtf/statuses/{sha}","languages_url":"https://api.github.com/repos/benbjohnson/wtf/languages","stargazers_url":"https://api.github.com/repos/benbjohnson/wtf/stargazers","contributors_url":"https://api.github.com/repos/benbjohnson/wtf/contributors","subscribers_url":"https://api.github.com/repos/benbjohnson/wtf/subscribers","subscription_url":"https://api.github.com/repos/benbjohnson/wtf/subscription","commits_url":"https://api.github.com/repos/benbjohnson/wtf/commits{/sha}","git_commits_url":"https://api.github.com/repos/benbjohnson/wtf/git/commits{/sha}","comments_url":"https://api.github.com/repos/benbjohnson/wtf/comments{/number}","issue_comment_url":"https://api.github.com/repos/benbjohnson/wtf/issues/comments{/number}","contents_url":"https://api.github.com/repos/benbjohnson/wtf/contents/{+path}","compare_url":"https://api.github.com/repos/benbjohnson/wtf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benbjohnson/wtf/merges","archive_url":"https://api.github.com/repos/benbjohnson/wtf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benbjohnson/wtf/downloads","issues_url":"https://api.github.com/repos/benbjohnson/wtf/issues{/number}","pulls_url":"https://api.github.com/repos/benbjohnson/wtf/pulls{/number}","milestones_url":"https://api.github.com/repos/benbjohnson/wtf/milestones{/number}","notifications_url":"https://api.github.com/repos/benbjohnson/wtf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benbjohnson/wtf/labels{/name}","releases_url":"https://api.github.com/repos/benbjohnson/wtf/releases{/id}","deployments_url":"https://api.github.com/repos/benbjohnson/wtf/deployments","created_at":"2016-08-17T21:59:01Z","updated_at":"2016-12-13T11:30:24Z","pushed_at":"2016-10-07T16:19:28Z","git_url":"git://github.com/benbjohnson/wtf.git","ssh_url":"git@github.com:benbjohnson/wtf.git","clone_url":"https://github.com/benbjohnson/wtf.git","svn_url":"https://github.com/benbjohnson/wtf","homepage":"http://dial.wtf","size":29,"stargazers_count":97,"watchers_count":97,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":97,"default_branch":"master"}},"base":{"label":"benbjohnson:master","ref":"master","sha":"eeab3970cd774fd6e5219cff0342342d756b4f7e","user":{"login":"benbjohnson","id":118015,"avatar_url":"https://avatars.githubusercontent.com/u/118015?v=3","gravatar_id":"","url":"https://api.github.com/users/benbjohnson","html_url":"https://github.com/benbjohnson","followers_url":"https://api.github.com/users/benbjohnson/followers","following_url":"https://api.github.com/users/benbjohnson/following{/other_user}","gists_url":"https://api.github.com/users/benbjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/benbjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbjohnson/subscriptions","organizations_url":"https://api.github.com/users/benbjohnson/orgs","repos_url":"https://api.github.com/users/benbjohnson/repos","events_url":"https://api.github.com/users/benbjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/benbjohnson/received_events","type":"User","site_admin":false},"repo":{"id":65945013,"name":"wtf","full_name":"benbjohnson/wtf","owner":{"login":"benbjohnson","id":118015,"avatar_url":"https://avatars.githubusercontent.com/u/118015?v=3","gravatar_id":"","url":"https://api.github.com/users/benbjohnson","html_url":"https://github.com/benbjohnson","followers_url":"https://api.github.com/users/benbjohnson/followers","following_url":"https://api.github.com/users/benbjohnson/following{/other_user}","gists_url":"https://api.github.com/users/benbjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/benbjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benbjohnson/subscriptions","organizations_url":"https://api.github.com/users/benbjohnson/orgs","repos_url":"https://api.github.com/users/benbjohnson/repos","events_url":"https://api.github.com/users/benbjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/benbjohnson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benbjohnson/wtf","description":"Real-time WTF status","fork":false,"url":"https://api.github.com/repos/benbjohnson/wtf","forks_url":"https://api.github.com/repos/benbjohnson/wtf/forks","keys_url":"https://api.github.com/repos/benbjohnson/wtf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benbjohnson/wtf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benbjohnson/wtf/teams","hooks_url":"https://api.github.com/repos/benbjohnson/wtf/hooks","issue_events_url":"https://api.github.com/repos/benbjohnson/wtf/issues/events{/number}","events_url":"https://api.github.com/repos/benbjohnson/wtf/events","assignees_url":"https://api.github.com/repos/benbjohnson/wtf/assignees{/user}","branches_url":"https://api.github.com/repos/benbjohnson/wtf/branches{/branch}","tags_url":"https://api.github.com/repos/benbjohnson/wtf/tags","blobs_url":"https://api.github.com/repos/benbjohnson/wtf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benbjohnson/wtf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benbjohnson/wtf/git/refs{/sha}","trees_url":"https://api.github.com/repos/benbjohnson/wtf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benbjohnson/wtf/statuses/{sha}","languages_url":"https://api.github.com/repos/benbjohnson/wtf/languages","stargazers_url":"https://api.github.com/repos/benbjohnson/wtf/stargazers","contributors_url":"https://api.github.com/repos/benbjohnson/wtf/contributors","subscribers_url":"https://api.github.com/repos/benbjohnson/wtf/subscribers","subscription_url":"https://api.github.com/repos/benbjohnson/wtf/subscription","commits_url":"https://api.github.com/repos/benbjohnson/wtf/commits{/sha}","git_commits_url":"https://api.github.com/repos/benbjohnson/wtf/git/commits{/sha}","comments_url":"https://api.github.com/repos/benbjohnson/wtf/comments{/number}","issue_comment_url":"https://api.github.com/repos/benbjohnson/wtf/issues/comments{/number}","contents_url":"https://api.github.com/repos/benbjohnson/wtf/contents/{+path}","compare_url":"https://api.github.com/repos/benbjohnson/wtf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benbjohnson/wtf/merges","archive_url":"https://api.github.com/repos/benbjohnson/wtf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benbjohnson/wtf/downloads","issues_url":"https://api.github.com/repos/benbjohnson/wtf/issues{/number}","pulls_url":"https://api.github.com/repos/benbjohnson/wtf/pulls{/number}","milestones_url":"https://api.github.com/repos/benbjohnson/wtf/milestones{/number}","notifications_url":"https://api.github.com/repos/benbjohnson/wtf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benbjohnson/wtf/labels{/name}","releases_url":"https://api.github.com/repos/benbjohnson/wtf/releases{/id}","deployments_url":"https://api.github.com/repos/benbjohnson/wtf/deployments","created_at":"2016-08-17T21:59:01Z","updated_at":"2016-12-13T11:30:24Z","pushed_at":"2016-10-07T16:19:28Z","git_url":"git://github.com/benbjohnson/wtf.git","ssh_url":"git@github.com:benbjohnson/wtf.git","clone_url":"https://github.com/benbjohnson/wtf.git","svn_url":"https://github.com/benbjohnson/wtf","homepage":"http://dial.wtf","size":29,"stargazers_count":97,"watchers_count":97,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":97,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/benbjohnson/wtf/pulls/8"},"html":{"href":"https://github.com/benbjohnson/wtf/pull/8"},"issue":{"href":"https://api.github.com/repos/benbjohnson/wtf/issues/8"},"comments":{"href":"https://api.github.com/repos/benbjohnson/wtf/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/benbjohnson/wtf/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/benbjohnson/wtf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/benbjohnson/wtf/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/benbjohnson/wtf/statuses/6d855c355488361b22b1a5ba13d9453e39141292"}}}}
{"actor":{"display_login":"billbell73"}}