{"action":"created","comment":{"url":"https://api.github.com/repos/k8sp/graphviz/pulls/comments/87671484","pull_request_review_id":8278699,"id":87671484,"diff_hunk":"@@ -0,0 +1,73 @@\n+// graphviz is an HTTP server which calls GraphViz's dot command to\n+// visualize a .dot file given in the `dot` parameter.  For example,\n+// we can run this program as follows\n+//\n+//   go run graphviz.go\n+//\n+// and access it from the Web browser with URL:\n+//\n+//   http://localhost:8080/?dot=https://gist.githubusercontent.com/wangkuiyi/c4e0015211dd1b9bde2e20455a6cd38e/raw/4d5ec099f98a5f326cf6f108bcf510cadba1a0b4/ci-arch.dot\n+//\n+// then the visualization of ci-arch.dot should appear in the browser window.\n+//\n+package main\n+\n+import (\n+\t\"crypto/md5\"\n+\t\"flag\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"log\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"os/exec\"\n+\t\"path\"\n+\n+\t\"github.com/topicai/candy\"\n+)\n+\n+func main() {\n+\tdir := flag.String(\"dir\", \"/tmp\", \"The cache directory\")\n+\taddr := flag.String(\"addr\", \":8080\", \"The listening address\")\n+\tflag.Parse()\n+\n+\thttp.HandleFunc(\"/\",\n+\t\tmakeSafeHandler(func(w http.ResponseWriter, r *http.Request) {\n+\t\t\tif source := r.FormValue(\"dot\"); len(source) > 0 {\n+\t\t\t\tdot, e := candy.HTTPGet(source, 0)\n+\t\t\t\tcandy.Must(e)\n+\n+\t\t\t\tid := fmt.Sprintf(\"%015x\", md5.Sum(dot))\n+\t\t\t\tdotFile := path.Join(*dir, id) + \".dot\"\n+\t\t\t\tpngFile := path.Join(*dir, id) + \".png\"\n+\n+\t\t\t\tif _, e := os.Stat(pngFile); os.IsNotExist(e) {\n+\t\t\t\t\t// TODO(yi): Here we adopt an unlimted-size disk-based cache.  We should\n+\t\t\t\t\t// either introduce LRU and limit the size, or periodically clean it.\n+\t\t\t\t\tlog.Printf(\"Update cache for %s\", pngFile)\n+\t\t\t\t\tcandy.Must(ioutil.WriteFile(dotFile, dot, 0755))\n+\t\t\t\t\tpng, e := exec.Command(\"dot\", \"-Tpng\", dotFile).Output()\n+\t\t\t\t\tcandy.Must(e)\n+\t\t\t\t\tcandy.Must(ioutil.WriteFile(pngFile, png, 0755))\n+\t\t\t\t}\n+\n+\t\t\t\tpng, e := ioutil.ReadFile(pngFile)\n+\t\t\t\tcandy.Must(e)\n+\t\t\t\t_, e = w.Write(png)","path":"graphviz.go","position":56,"original_position":56,"commit_id":"fae68559a359ade5554ef57be58be71475b74dc2","original_commit_id":"fae68559a359ade5554ef57be58be71475b74dc2","user":{"login":"helinwang","id":1724178,"avatar_url":"https://avatars.githubusercontent.com/u/1724178?v=3","gravatar_id":"","url":"https://api.github.com/users/helinwang","html_url":"https://github.com/helinwang","followers_url":"https://api.github.com/users/helinwang/followers","following_url":"https://api.github.com/users/helinwang/following{/other_user}","gists_url":"https://api.github.com/users/helinwang/gists{/gist_id}","starred_url":"https://api.github.com/users/helinwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helinwang/subscriptions","organizations_url":"https://api.github.com/users/helinwang/orgs","repos_url":"https://api.github.com/users/helinwang/repos","events_url":"https://api.github.com/users/helinwang/events{/privacy}","received_events_url":"https://api.github.com/users/helinwang/received_events","type":"User","site_admin":false},"body":"Good point, `Content-Type` http package will not know, so programmer have to set if she wishes.\r\n`Content-Length` I think will be automatically set by http package.\r\nAnyway, I think most of the browsers are able to detect `Content-Type` if it's not set. For png file there will be a png signature at the beginning of the png binary.\r\n","created_at":"2016-11-11T22:50:51Z","updated_at":"2016-11-11T22:51:38Z","html_url":"https://github.com/k8sp/graphviz/pull/3#discussion_r87671484","pull_request_url":"https://api.github.com/repos/k8sp/graphviz/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/k8sp/graphviz/pulls/comments/87671484"},"html":{"href":"https://github.com/k8sp/graphviz/pull/3#discussion_r87671484"},"pull_request":{"href":"https://api.github.com/repos/k8sp/graphviz/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/k8sp/graphviz/pulls/3","id":93017378,"html_url":"https://github.com/k8sp/graphviz/pull/3","diff_url":"https://github.com/k8sp/graphviz/pull/3.diff","patch_url":"https://github.com/k8sp/graphviz/pull/3.patch","issue_url":"https://api.github.com/repos/k8sp/graphviz/issues/3","number":3,"state":"open","locked":false,"title":"Release 0.1","user":{"login":"wangkuiyi","id":1548775,"avatar_url":"https://avatars.githubusercontent.com/u/1548775?v=3","gravatar_id":"","url":"https://api.github.com/users/wangkuiyi","html_url":"https://github.com/wangkuiyi","followers_url":"https://api.github.com/users/wangkuiyi/followers","following_url":"https://api.github.com/users/wangkuiyi/following{/other_user}","gists_url":"https://api.github.com/users/wangkuiyi/gists{/gist_id}","starred_url":"https://api.github.com/users/wangkuiyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wangkuiyi/subscriptions","organizations_url":"https://api.github.com/users/wangkuiyi/orgs","repos_url":"https://api.github.com/users/wangkuiyi/repos","events_url":"https://api.github.com/users/wangkuiyi/events{/privacy}","received_events_url":"https://api.github.com/users/wangkuiyi/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-09T18:49:05Z","updated_at":"2016-11-11T22:51:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7fbf026c90429bd4d10ec1d89e14d220fde97f6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/k8sp/graphviz/pulls/3/commits","review_comments_url":"https://api.github.com/repos/k8sp/graphviz/pulls/3/comments","review_comment_url":"https://api.github.com/repos/k8sp/graphviz/pulls/comments{/number}","comments_url":"https://api.github.com/repos/k8sp/graphviz/issues/3/comments","statuses_url":"https://api.github.com/repos/k8sp/graphviz/statuses/fae68559a359ade5554ef57be58be71475b74dc2","head":{"label":"k8sp:develop","ref":"develop","sha":"fae68559a359ade5554ef57be58be71475b74dc2","user":{"login":"k8sp","id":19252557,"avatar_url":"https://avatars.githubusercontent.com/u/19252557?v=3","gravatar_id":"","url":"https://api.github.com/users/k8sp","html_url":"https://github.com/k8sp","followers_url":"https://api.github.com/users/k8sp/followers","following_url":"https://api.github.com/users/k8sp/following{/other_user}","gists_url":"https://api.github.com/users/k8sp/gists{/gist_id}","starred_url":"https://api.github.com/users/k8sp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k8sp/subscriptions","organizations_url":"https://api.github.com/users/k8sp/orgs","repos_url":"https://api.github.com/users/k8sp/repos","events_url":"https://api.github.com/users/k8sp/events{/privacy}","received_events_url":"https://api.github.com/users/k8sp/received_events","type":"Organization","site_admin":false},"repo":{"id":72685653,"name":"graphviz","full_name":"k8sp/graphviz","owner":{"login":"k8sp","id":19252557,"avatar_url":"https://avatars.githubusercontent.com/u/19252557?v=3","gravatar_id":"","url":"https://api.github.com/users/k8sp","html_url":"https://github.com/k8sp","followers_url":"https://api.github.com/users/k8sp/followers","following_url":"https://api.github.com/users/k8sp/following{/other_user}","gists_url":"https://api.github.com/users/k8sp/gists{/gist_id}","starred_url":"https://api.github.com/users/k8sp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k8sp/subscriptions","organizations_url":"https://api.github.com/users/k8sp/orgs","repos_url":"https://api.github.com/users/k8sp/repos","events_url":"https://api.github.com/users/k8sp/events{/privacy}","received_events_url":"https://api.github.com/users/k8sp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/k8sp/graphviz","description":"A Golang GraphViz server used to generate inline images from .dot files.","fork":false,"url":"https://api.github.com/repos/k8sp/graphviz","forks_url":"https://api.github.com/repos/k8sp/graphviz/forks","keys_url":"https://api.github.com/repos/k8sp/graphviz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/k8sp/graphviz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/k8sp/graphviz/teams","hooks_url":"https://api.github.com/repos/k8sp/graphviz/hooks","issue_events_url":"https://api.github.com/repos/k8sp/graphviz/issues/events{/number}","events_url":"https://api.github.com/repos/k8sp/graphviz/events","assignees_url":"https://api.github.com/repos/k8sp/graphviz/assignees{/user}","branches_url":"https://api.github.com/repos/k8sp/graphviz/branches{/branch}","tags_url":"https://api.github.com/repos/k8sp/graphviz/tags","blobs_url":"https://api.github.com/repos/k8sp/graphviz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/k8sp/graphviz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/k8sp/graphviz/git/refs{/sha}","trees_url":"https://api.github.com/repos/k8sp/graphviz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/k8sp/graphviz/statuses/{sha}","languages_url":"https://api.github.com/repos/k8sp/graphviz/languages","stargazers_url":"https://api.github.com/repos/k8sp/graphviz/stargazers","contributors_url":"https://api.github.com/repos/k8sp/graphviz/contributors","subscribers_url":"https://api.github.com/repos/k8sp/graphviz/subscribers","subscription_url":"https://api.github.com/repos/k8sp/graphviz/subscription","commits_url":"https://api.github.com/repos/k8sp/graphviz/commits{/sha}","git_commits_url":"https://api.github.com/repos/k8sp/graphviz/git/commits{/sha}","comments_url":"https://api.github.com/repos/k8sp/graphviz/comments{/number}","issue_comment_url":"https://api.github.com/repos/k8sp/graphviz/issues/comments{/number}","contents_url":"https://api.github.com/repos/k8sp/graphviz/contents/{+path}","compare_url":"https://api.github.com/repos/k8sp/graphviz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/k8sp/graphviz/merges","archive_url":"https://api.github.com/repos/k8sp/graphviz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/k8sp/graphviz/downloads","issues_url":"https://api.github.com/repos/k8sp/graphviz/issues{/number}","pulls_url":"https://api.github.com/repos/k8sp/graphviz/pulls{/number}","milestones_url":"https://api.github.com/repos/k8sp/graphviz/milestones{/number}","notifications_url":"https://api.github.com/repos/k8sp/graphviz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/k8sp/graphviz/labels{/name}","releases_url":"https://api.github.com/repos/k8sp/graphviz/releases{/id}","deployments_url":"https://api.github.com/repos/k8sp/graphviz/deployments","created_at":"2016-11-02T22:09:44Z","updated_at":"2016-11-09T02:10:12Z","pushed_at":"2016-11-09T18:49:05Z","git_url":"git://github.com/k8sp/graphviz.git","ssh_url":"git@github.com:k8sp/graphviz.git","clone_url":"https://github.com/k8sp/graphviz.git","svn_url":"https://github.com/k8sp/graphviz","homepage":null,"size":4,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"develop"}},"base":{"label":"k8sp:master","ref":"master","sha":"f9ce1b15b1ede9819850b987e6ef0232d44169d7","user":{"login":"k8sp","id":19252557,"avatar_url":"https://avatars.githubusercontent.com/u/19252557?v=3","gravatar_id":"","url":"https://api.github.com/users/k8sp","html_url":"https://github.com/k8sp","followers_url":"https://api.github.com/users/k8sp/followers","following_url":"https://api.github.com/users/k8sp/following{/other_user}","gists_url":"https://api.github.com/users/k8sp/gists{/gist_id}","starred_url":"https://api.github.com/users/k8sp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k8sp/subscriptions","organizations_url":"https://api.github.com/users/k8sp/orgs","repos_url":"https://api.github.com/users/k8sp/repos","events_url":"https://api.github.com/users/k8sp/events{/privacy}","received_events_url":"https://api.github.com/users/k8sp/received_events","type":"Organization","site_admin":false},"repo":{"id":72685653,"name":"graphviz","full_name":"k8sp/graphviz","owner":{"login":"k8sp","id":19252557,"avatar_url":"https://avatars.githubusercontent.com/u/19252557?v=3","gravatar_id":"","url":"https://api.github.com/users/k8sp","html_url":"https://github.com/k8sp","followers_url":"https://api.github.com/users/k8sp/followers","following_url":"https://api.github.com/users/k8sp/following{/other_user}","gists_url":"https://api.github.com/users/k8sp/gists{/gist_id}","starred_url":"https://api.github.com/users/k8sp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k8sp/subscriptions","organizations_url":"https://api.github.com/users/k8sp/orgs","repos_url":"https://api.github.com/users/k8sp/repos","events_url":"https://api.github.com/users/k8sp/events{/privacy}","received_events_url":"https://api.github.com/users/k8sp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/k8sp/graphviz","description":"A Golang GraphViz server used to generate inline images from .dot files.","fork":false,"url":"https://api.github.com/repos/k8sp/graphviz","forks_url":"https://api.github.com/repos/k8sp/graphviz/forks","keys_url":"https://api.github.com/repos/k8sp/graphviz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/k8sp/graphviz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/k8sp/graphviz/teams","hooks_url":"https://api.github.com/repos/k8sp/graphviz/hooks","issue_events_url":"https://api.github.com/repos/k8sp/graphviz/issues/events{/number}","events_url":"https://api.github.com/repos/k8sp/graphviz/events","assignees_url":"https://api.github.com/repos/k8sp/graphviz/assignees{/user}","branches_url":"https://api.github.com/repos/k8sp/graphviz/branches{/branch}","tags_url":"https://api.github.com/repos/k8sp/graphviz/tags","blobs_url":"https://api.github.com/repos/k8sp/graphviz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/k8sp/graphviz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/k8sp/graphviz/git/refs{/sha}","trees_url":"https://api.github.com/repos/k8sp/graphviz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/k8sp/graphviz/statuses/{sha}","languages_url":"https://api.github.com/repos/k8sp/graphviz/languages","stargazers_url":"https://api.github.com/repos/k8sp/graphviz/stargazers","contributors_url":"https://api.github.com/repos/k8sp/graphviz/contributors","subscribers_url":"https://api.github.com/repos/k8sp/graphviz/subscribers","subscription_url":"https://api.github.com/repos/k8sp/graphviz/subscription","commits_url":"https://api.github.com/repos/k8sp/graphviz/commits{/sha}","git_commits_url":"https://api.github.com/repos/k8sp/graphviz/git/commits{/sha}","comments_url":"https://api.github.com/repos/k8sp/graphviz/comments{/number}","issue_comment_url":"https://api.github.com/repos/k8sp/graphviz/issues/comments{/number}","contents_url":"https://api.github.com/repos/k8sp/graphviz/contents/{+path}","compare_url":"https://api.github.com/repos/k8sp/graphviz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/k8sp/graphviz/merges","archive_url":"https://api.github.com/repos/k8sp/graphviz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/k8sp/graphviz/downloads","issues_url":"https://api.github.com/repos/k8sp/graphviz/issues{/number}","pulls_url":"https://api.github.com/repos/k8sp/graphviz/pulls{/number}","milestones_url":"https://api.github.com/repos/k8sp/graphviz/milestones{/number}","notifications_url":"https://api.github.com/repos/k8sp/graphviz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/k8sp/graphviz/labels{/name}","releases_url":"https://api.github.com/repos/k8sp/graphviz/releases{/id}","deployments_url":"https://api.github.com/repos/k8sp/graphviz/deployments","created_at":"2016-11-02T22:09:44Z","updated_at":"2016-11-09T02:10:12Z","pushed_at":"2016-11-09T18:49:05Z","git_url":"git://github.com/k8sp/graphviz.git","ssh_url":"git@github.com:k8sp/graphviz.git","clone_url":"https://github.com/k8sp/graphviz.git","svn_url":"https://github.com/k8sp/graphviz","homepage":null,"size":4,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/k8sp/graphviz/pulls/3"},"html":{"href":"https://github.com/k8sp/graphviz/pull/3"},"issue":{"href":"https://api.github.com/repos/k8sp/graphviz/issues/3"},"comments":{"href":"https://api.github.com/repos/k8sp/graphviz/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/k8sp/graphviz/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/k8sp/graphviz/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/k8sp/graphviz/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/k8sp/graphviz/statuses/fae68559a359ade5554ef57be58be71475b74dc2"}}}}
{"actor":{"display_login":"helinwang"}}