{"action":"created","issue":{"url":"https://api.github.com/repos/coreos/etcd/issues/3579","labels_url":"https://api.github.com/repos/coreos/etcd/issues/3579/labels{/name}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/3579/comments","events_url":"https://api.github.com/repos/coreos/etcd/issues/3579/events","html_url":"https://github.com/coreos/etcd/pull/3579","id":107871443,"number":3579,"title":"httptypes: WriteTo to return error","user":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars.githubusercontent.com/u/6799218?v=3","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-23T08:25:23Z","updated_at":"2015-09-25T22:00:39Z","closed_at":"2015-09-25T21:31:48Z","pull_request":{"url":"https://api.github.com/repos/coreos/etcd/pulls/3579","html_url":"https://github.com/coreos/etcd/pull/3579","diff_url":"https://github.com/coreos/etcd/pull/3579.diff","patch_url":"https://github.com/coreos/etcd/pull/3579.patch"},"body":"This is a new pull request following up with https://github.com/coreos/etcd/pull/3574.\r\n@xiang90 suggested just to return error. This PR changes it to such interface.\r\nThis API change should be compatible in general, since the code before this did\r\nnot return any value to be evaluated. I might be missing some changes, and\r\nwasn't sure about what would be the best way to handle this error.\r\n\r\nAnd this would make it seem inconsistent with other APIs as in `rafthttp`[1]\r\nand `error`[2]:\r\n\r\n```\r\n// TODO(xiangli): handle http write errors\r\nfunc (e HTTPError) WriteTo(w http.ResponseWriter) {\r\n\tw.Header().Set(\"Content-Type\", \"application/json\")\r\n\tw.WriteHeader(e.Code)\r\n\tb, err := json.Marshal(e)\r\n\tif err != nil {\r\n\t\tplog.Panicf(\"marshal HTTPError should never fail (%v)\", err)\r\n\t}\r\n\tw.Write(b)\r\n}\r\n\r\ntype writerToResponse interface {\r\n\tWriteTo(w http.ResponseWriter)\r\n}\r\n\r\nfunc (e Error) WriteTo(w http.ResponseWriter) {\r\n\tw.Header().Add(\"X-Etcd-Index\", fmt.Sprint(e.Index))\r\n\tw.Header().Set(\"Content-Type\", \"application/json\")\r\n\tw.WriteHeader(e.statusCode())\r\n\tfmt.Fprintln(w, e.toJsonString())\r\n}\r\n\r\n```\r\n\r\nPlease let me know if you have any feedback. And thanks!\r\n\r\n---\r\n1. https://github.com/coreos/etcd/blob/master/rafthttp/http.go#L63-L65\r\n2. https://github.com/coreos/etcd/blob/master/error/error.go#L154-L159"},"comment":{"url":"https://api.github.com/repos/coreos/etcd/issues/comments/143363687","html_url":"https://github.com/coreos/etcd/pull/3579#issuecomment-143363687","issue_url":"https://api.github.com/repos/coreos/etcd/issues/3579","id":143363687,"user":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars.githubusercontent.com/u/6799218?v=3","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T22:00:39Z","updated_at":"2015-09-25T22:00:39Z","body":"Thank you!"}}