{"action":"created","comment":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/23602049","id":23602049,"diff_hunk":"@@ -6,11 +6,13 @@ import (\n \tcore \"github.com/jbenet/go-ipfs/core\"\n )\n \n-func GatewayOption(n *core.IpfsNode, mux *http.ServeMux) error {\n-\tgateway, err := newGatewayHandler(n)\n-\tif err != nil {\n-\t\treturn err\n+func GatewayOption(writable bool) ServeOption {\n+\treturn func(n *core.IpfsNode, mux *http.ServeMux) error {\n+\t\tgateway, err := newGatewayHandler(n, writable)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tmux.Handle(\"/ipfs/\", gateway)","path":"core/corehttp/gateway.go","position":14,"original_position":14,"commit_id":"e258f231538ae6c697aaa9ac307797f7edcf4746","original_commit_id":"e258f231538ae6c697aaa9ac307797f7edcf4746","user":{"login":"briantigerchow","id":734339,"avatar_url":"https://avatars.githubusercontent.com/u/734339?v=3","gravatar_id":"","url":"https://api.github.com/users/briantigerchow","html_url":"https://github.com/briantigerchow","followers_url":"https://api.github.com/users/briantigerchow/followers","following_url":"https://api.github.com/users/briantigerchow/following{/other_user}","gists_url":"https://api.github.com/users/briantigerchow/gists{/gist_id}","starred_url":"https://api.github.com/users/briantigerchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briantigerchow/subscriptions","organizations_url":"https://api.github.com/users/briantigerchow/orgs","repos_url":"https://api.github.com/users/briantigerchow/repos","events_url":"https://api.github.com/users/briantigerchow/events{/privacy}","received_events_url":"https://api.github.com/users/briantigerchow/received_events","type":"User","site_admin":false},"body":"There's some complexity emerging in `ServeHTTP`. There may be a simpler way to handle multiple HTTP methods on the same path. If we switch over to the gorilla mux, we get the following...\r\n\r\n```Go\r\nstate := &gatewayState{node: n, writable: writable, dir: load()}\r\nipfsPath := r.PathPrefix(\"/ipfs/\").Subrouter()\r\nipfsPath.Methods(\"GET\").HandlerFunc(getHandler(state))\r\nipfsPath.Methods(\"PUT\").HandlerFunc(putHandler(state))\r\nipfsPath.Methods(\"POST\").HandlerFunc(postHandler(state))\r\nipfsPath.Methods(\"DELETE\").HandlerFunc(deleteHandler(state))\r\n```\r\n\r\nThoughts?","created_at":"2015-01-27T11:38:47Z","updated_at":"2015-01-27T11:38:47Z","html_url":"https://github.com/jbenet/go-ipfs/pull/617#discussion_r23602049","pull_request_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617","_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/23602049"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/617#discussion_r23602049"},"pull_request":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617"}}},"pull_request":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617","id":27826550,"html_url":"https://github.com/jbenet/go-ipfs/pull/617","diff_url":"https://github.com/jbenet/go-ipfs/pull/617.diff","patch_url":"https://github.com/jbenet/go-ipfs/pull/617.patch","issue_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/617","number":617,"state":"open","locked":false,"title":"HTTP: add handlers to allow object creation and modification","user":{"login":"mildred","id":33804,"avatar_url":"https://avatars.githubusercontent.com/u/33804?v=3","gravatar_id":"","url":"https://api.github.com/users/mildred","html_url":"https://github.com/mildred","followers_url":"https://api.github.com/users/mildred/followers","following_url":"https://api.github.com/users/mildred/following{/other_user}","gists_url":"https://api.github.com/users/mildred/gists{/gist_id}","starred_url":"https://api.github.com/users/mildred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mildred/subscriptions","organizations_url":"https://api.github.com/users/mildred/orgs","repos_url":"https://api.github.com/users/mildred/repos","events_url":"https://api.github.com/users/mildred/events{/privacy}","received_events_url":"https://api.github.com/users/mildred/received_events","type":"User","site_admin":false},"body":"This is for issue #611 ","created_at":"2015-01-22T08:54:15Z","updated_at":"2015-01-27T11:38:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4243ed081896307bac3f0ec4d93c0b45345156f8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617/commits","review_comments_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617/comments","review_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/617/comments","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/e258f231538ae6c697aaa9ac307797f7edcf4746","head":{"label":"mildred:http-rest","ref":"http-rest","sha":"e258f231538ae6c697aaa9ac307797f7edcf4746","user":{"login":"mildred","id":33804,"avatar_url":"https://avatars.githubusercontent.com/u/33804?v=3","gravatar_id":"","url":"https://api.github.com/users/mildred","html_url":"https://github.com/mildred","followers_url":"https://api.github.com/users/mildred/followers","following_url":"https://api.github.com/users/mildred/following{/other_user}","gists_url":"https://api.github.com/users/mildred/gists{/gist_id}","starred_url":"https://api.github.com/users/mildred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mildred/subscriptions","organizations_url":"https://api.github.com/users/mildred/orgs","repos_url":"https://api.github.com/users/mildred/repos","events_url":"https://api.github.com/users/mildred/events{/privacy}","received_events_url":"https://api.github.com/users/mildred/received_events","type":"User","site_admin":false},"repo":{"id":24406198,"name":"go-ipfs","full_name":"mildred/go-ipfs","owner":{"login":"mildred","id":33804,"avatar_url":"https://avatars.githubusercontent.com/u/33804?v=3","gravatar_id":"","url":"https://api.github.com/users/mildred","html_url":"https://github.com/mildred","followers_url":"https://api.github.com/users/mildred/followers","following_url":"https://api.github.com/users/mildred/following{/other_user}","gists_url":"https://api.github.com/users/mildred/gists{/gist_id}","starred_url":"https://api.github.com/users/mildred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mildred/subscriptions","organizations_url":"https://api.github.com/users/mildred/orgs","repos_url":"https://api.github.com/users/mildred/repos","events_url":"https://api.github.com/users/mildred/events{/privacy}","received_events_url":"https://api.github.com/users/mildred/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mildred/go-ipfs","description":"ipfs implementation in go","fork":true,"url":"https://api.github.com/repos/mildred/go-ipfs","forks_url":"https://api.github.com/repos/mildred/go-ipfs/forks","keys_url":"https://api.github.com/repos/mildred/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mildred/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mildred/go-ipfs/teams","hooks_url":"https://api.github.com/repos/mildred/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/mildred/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/mildred/go-ipfs/events","assignees_url":"https://api.github.com/repos/mildred/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/mildred/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/mildred/go-ipfs/tags","blobs_url":"https://api.github.com/repos/mildred/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mildred/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mildred/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/mildred/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mildred/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/mildred/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/mildred/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/mildred/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/mildred/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/mildred/go-ipfs/subscription","commits_url":"https://api.github.com/repos/mildred/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/mildred/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/mildred/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/mildred/go-ipfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/mildred/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/mildred/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mildred/go-ipfs/merges","archive_url":"https://api.github.com/repos/mildred/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mildred/go-ipfs/downloads","issues_url":"https://api.github.com/repos/mildred/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/mildred/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/mildred/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/mildred/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mildred/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/mildred/go-ipfs/releases{/id}","created_at":"2014-09-24T08:04:35Z","updated_at":"2015-01-21T15:38:28Z","pushed_at":"2015-01-26T16:12:13Z","git_url":"git://github.com/mildred/go-ipfs.git","ssh_url":"git@github.com:mildred/go-ipfs.git","clone_url":"https://github.com/mildred/go-ipfs.git","svn_url":"https://github.com/mildred/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":14218,"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":"jbenet:master","ref":"master","sha":"77b88f446259bacca02252146da8ce6b14c66d64","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"jbenet/go-ipfs","owner":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jbenet/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/jbenet/go-ipfs","forks_url":"https://api.github.com/repos/jbenet/go-ipfs/forks","keys_url":"https://api.github.com/repos/jbenet/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-ipfs/teams","hooks_url":"https://api.github.com/repos/jbenet/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-ipfs/events","assignees_url":"https://api.github.com/repos/jbenet/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-ipfs/tags","blobs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-ipfs/subscription","commits_url":"https://api.github.com/repos/jbenet/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/jbenet/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-ipfs/merges","archive_url":"https://api.github.com/repos/jbenet/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-ipfs/downloads","issues_url":"https://api.github.com/repos/jbenet/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2015-01-27T07:49:23Z","pushed_at":"2015-01-27T09:38:42Z","git_url":"git://github.com/jbenet/go-ipfs.git","ssh_url":"git@github.com:jbenet/go-ipfs.git","clone_url":"https://github.com/jbenet/go-ipfs.git","svn_url":"https://github.com/jbenet/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":24437,"stargazers_count":255,"watchers_count":255,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":146,"forks":35,"open_issues":146,"watchers":255,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/617"},"issue":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/617"},"comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/617/comments"},"review_comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617/comments"},"review_comment":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/617/commits"},"statuses":{"href":"https://api.github.com/repos/jbenet/go-ipfs/statuses/e258f231538ae6c697aaa9ac307797f7edcf4746"}}}}