GitHub PullRequestReviewCommentEvent at 2014-09-12 19:28:51
Repository: flynn
Actor: titanous
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/flynn/flynn/pulls/comments/17497926","id":17497926,"diff_hunk":"@@ -0,0 +1,153 @@\n+package main\n+\n+import (\n+\t\"crypto/subtle\"\n+\t\"fmt\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"strings\"\n+\t\"time\"\n+\n+\t\"github.com/flynn/flynn/Godeps/_workspace/src/github.com/badgerodon/ioutil\"\n+\t\"github.com/flynn/flynn/Godeps/_workspace/src/github.com/go-martini/martini\"\n+\t\"github.com/flynn/flynn/Godeps/_workspace/src/github.com/martini-contrib/binding\"\n+\t\"github.com/flynn/flynn/Godeps/_workspace/src/github.com/martini-contrib/render\"\n+\t\"github.com/flynn/flynn/pkg/cors\"\n+)\n+\n+type LoginInfo struct {\n+\tToken string `json:\"token\"`\n+}\n+\n+func APIHandler(conf *Config) http.Handler {\n+\tr := martini.NewRouter()\n+\tm := martini.New()\n+\tm.Use(martini.Logger())\n+\tm.Use(martini.Recovery())\n+\tm.Use(render.Renderer(render.Options{\n+\t\tDirectory:  \"app/build\",\n+\t\tExtensions: []string{\".html\"},\n+\t}))\n+\tm.Action(r.Handle)\n+\n+\tm.Map(conf)\n+\n+\tm.Use(cors.Allow(&cors.Options{\n+\t\tAllowOrigins:     []string{conf.InterfaceURL},\n+\t\tAllowMethods:     []string{\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\", \"HEAD\"},\n+\t\tAllowHeaders:     []string{\"Authorization\", \"Accept\", \"Content-Type\", \"If-Match\", \"If-None-Match\"},\n+\t\tExposeHeaders:    []string{\"ETag\"},\n+\t\tAllowCredentials: true,\n+\t\tMaxAge:           time.Hour,\n+\t}))\n+\n+\tr.Group(conf.PathPrefix, func(r martini.Router) {\n+\t\tm.Use(reqHelperMiddleware)\n+\t\tr.Post(\"/user/sessions\", binding.Json(LoginInfo{}), login)\n+\t\tr.Delete(\"/user/session\", logout)\n+\n+\t\tr.Get(\"/config\", getConfig)\n+\n+\t\tr.Any(\"/assets/application.*.js\", serveApplicationJs)\n+\n+\t\tr.Any(\"/assets.*\", martini.Static(\"app/build/assets\", martini.StaticOptions{\n+\t\t\tPrefix: \"/assets\",\n+\t\t}))\n+\n+\t\tr.Get(\"/.*\", func(r render.Render) {\n+\t\t\tr.HTML(200, \"dashboard\", \"\")\n+\t\t})\n+\t})\n+\n+\treturn m\n+}\n+\n+func requireUserMiddleware(rh RequestHelper) {\n+\tif !rh.IsAuthenticated() {\n+\t\trh.WriteHeader(401)\n+\t}\n+}\n+\n+func login(req *http.Request, w http.ResponseWriter, info LoginInfo, rh RequestHelper, conf *Config) {\n+\tif len(info.Token) != len(conf.LoginToken) || subtle.ConstantTimeCompare([]byte(info.Token), []byte(conf.LoginToken)) != 1 {\n+\t\trh.Error(ErrInvalidLoginToken)\n+\t\treturn\n+\t}\n+\trh.SetAuthenticated()\n+\trh.WriteHeader(200)\n+}\n+\n+func logout(req *http.Request, w http.ResponseWriter, rh RequestHelper) {\n+\trh.UnsetAuthenticated()\n+\trh.WriteHeader(200)\n+}\n+\n+type OAuthToken struct {\n+\tAccessToken string `json:\"access_token\"`\n+}\n+\n+type ExpandedUser struct {\n+\tAuths         map[string]*OAuthToken `json:\"auths\"`\n+\tControllerKey string                 `json:\"controller_key\"`\n+}\n+\n+type UserConfig struct {\n+\tUser *ExpandedUser `json:\"user,omitempty\"`\n+\n+\tEndpoints map[string]string `json:\"endpoints\"`\n+}\n+\n+var baseConfig = UserConfig{\n+\tEndpoints: map[string]string{\n+\t\t\"login\":  \"/user/sessions\",\n+\t\t\"logout\": \"/user/session\",\n+\t},\n+}\n+\n+func getConfig(rh RequestHelper, conf *Config) {\n+\tconfig := baseConfig\n+\n+\tconfig.Endpoints[\"cluster_controller\"] = fmt.Sprintf(\"http://%s\", conf.ClusterDomain)\n+\n+\tif rh.IsAuthenticated() {\n+\t\tconfig.User = &ExpandedUser{}\n+\t\tconfig.User.Auths = make(map[string]*OAuthToken)\n+\n+\t\tif conf.GithubToken != \"\" {\n+\t\t\tconfig.User.Auths[\"github\"] = &OAuthToken{AccessToken: conf.GithubToken}\n+\t\t}\n+\n+\t\tconfig.User.ControllerKey = conf.ControllerKey\n+\t}\n+\n+\trh.JSON(200, config)\n+}\n+\n+func serveApplicationJs(res http.ResponseWriter, req *http.Request, conf *Config) {\n+\tfile := req.URL.Path\n+\tfile = strings.TrimPrefix(file, \"/assets\")\n+\tfile = strings.Join([]string{\"app/build/assets\"}, file)","path":"dashboard/api.go","position":129,"original_position":129,"commit_id":"64bca7e08d61afedb975ff7cabe0f1b8fb013968","original_commit_id":"64bca7e08d61afedb975ff7cabe0f1b8fb013968","user":{"login":"titanous","id":13026,"avatar_url":"https://avatars.githubusercontent.com/u/13026?v=2","gravatar_id":"02319fb5cbcf9309a4bd0ea7c791e5d6","url":"https://api.github.com/users/titanous","html_url":"https://github.com/titanous","followers_url":"https://api.github.com/users/titanous/followers","following_url":"https://api.github.com/users/titanous/following{/other_user}","gists_url":"https://api.github.com/users/titanous/gists{/gist_id}","starred_url":"https://api.github.com/users/titanous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/titanous/subscriptions","organizations_url":"https://api.github.com/users/titanous/orgs","repos_url":"https://api.github.com/users/titanous/repos","events_url":"https://api.github.com/users/titanous/events{/privacy}","received_events_url":"https://api.github.com/users/titanous/received_events","type":"User","site_admin":false},"body":"```go\r\nfile := filepath.Join(\"app/build/assets\", filepath.Base(req.URL.Path))\r\n```","created_at":"2014-09-12T19:28:51Z","updated_at":"2014-09-12T19:28:51Z","html_url":"https://github.com/flynn/flynn/pull/191#discussion_r17497926","pull_request_url":"https://api.github.com/repos/flynn/flynn/pulls/191","_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments/17497926"},"html":{"href":"https://github.com/flynn/flynn/pull/191#discussion_r17497926"},"pull_request":{"href":"https://api.github.com/repos/flynn/flynn/pulls/191"}}},"pull_request":{"url":"https://api.github.com/repos/flynn/flynn/pulls/191","id":20710373,"html_url":"https://github.com/flynn/flynn/pull/191","diff_url":"https://github.com/flynn/flynn/pull/191.diff","patch_url":"https://github.com/flynn/flynn/pull/191.patch","issue_url":"https://api.github.com/repos/flynn/flynn/issues/191","number":191,"state":"open","locked":false,"title":"Dashboard","user":{"login":"jvatic","id":171040,"avatar_url":"https://avatars.githubusercontent.com/u/171040?v=2","gravatar_id":"6c5c0f5e8c16fee9ff04aa3afefe8b74","url":"https://api.github.com/users/jvatic","html_url":"https://github.com/jvatic","followers_url":"https://api.github.com/users/jvatic/followers","following_url":"https://api.github.com/users/jvatic/following{/other_user}","gists_url":"https://api.github.com/users/jvatic/gists{/gist_id}","starred_url":"https://api.github.com/users/jvatic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvatic/subscriptions","organizations_url":"https://api.github.com/users/jvatic/orgs","repos_url":"https://api.github.com/users/jvatic/repos","events_url":"https://api.github.com/users/jvatic/events{/privacy}","received_events_url":"https://api.github.com/users/jvatic/received_events","type":"User","site_admin":false},"body":"@titanous \r\n\r\nDashboard app + server","created_at":"2014-09-03T22:19:23Z","updated_at":"2014-09-12T19:28:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"806d1d995e5af13970648d3f275528197ed527a9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flynn/flynn/pulls/191/commits","review_comments_url":"https://api.github.com/repos/flynn/flynn/pulls/191/comments","review_comment_url":"https://api.github.com/repos/flynn/flynn/pulls/comments/{number}","comments_url":"https://api.github.com/repos/flynn/flynn/issues/191/comments","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/64bca7e08d61afedb975ff7cabe0f1b8fb013968","head":{"label":"flynn:dashboard","ref":"dashboard","sha":"64bca7e08d61afedb975ff7cabe0f1b8fb013968","user":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=2","gravatar_id":"0f81f5e29cb53c7545c5b77465d9b5c5","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"repo":{"id":11290232,"name":"flynn","full_name":"flynn/flynn","owner":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=2","gravatar_id":"0f81f5e29cb53c7545c5b77465d9b5c5","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flynn/flynn","description":"A next generation open source platform as a service (PaaS)","fork":false,"url":"https://api.github.com/repos/flynn/flynn","forks_url":"https://api.github.com/repos/flynn/flynn/forks","keys_url":"https://api.github.com/repos/flynn/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flynn/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flynn/flynn/teams","hooks_url":"https://api.github.com/repos/flynn/flynn/hooks","issue_events_url":"https://api.github.com/repos/flynn/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/flynn/flynn/events","assignees_url":"https://api.github.com/repos/flynn/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/flynn/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/flynn/flynn/tags","blobs_url":"https://api.github.com/repos/flynn/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flynn/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flynn/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/flynn/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/flynn/flynn/languages","stargazers_url":"https://api.github.com/repos/flynn/flynn/stargazers","contributors_url":"https://api.github.com/repos/flynn/flynn/contributors","subscribers_url":"https://api.github.com/repos/flynn/flynn/subscribers","subscription_url":"https://api.github.com/repos/flynn/flynn/subscription","commits_url":"https://api.github.com/repos/flynn/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/flynn/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/flynn/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/flynn/flynn/issues/comments/{number}","contents_url":"https://api.github.com/repos/flynn/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/flynn/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flynn/flynn/merges","archive_url":"https://api.github.com/repos/flynn/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flynn/flynn/downloads","issues_url":"https://api.github.com/repos/flynn/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/flynn/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/flynn/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/flynn/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flynn/flynn/labels{/name}","releases_url":"https://api.github.com/repos/flynn/flynn/releases{/id}","created_at":"2013-07-09T18:22:06Z","updated_at":"2014-09-12T18:12:41Z","pushed_at":"2014-09-12T19:26:46Z","git_url":"git://github.com/flynn/flynn.git","ssh_url":"git@github.com:flynn/flynn.git","clone_url":"https://github.com/flynn/flynn.git","svn_url":"https://github.com/flynn/flynn","homepage":"https://flynn.io","size":13349,"stargazers_count":2392,"watchers_count":2392,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":119,"mirror_url":null,"open_issues_count":67,"forks":119,"open_issues":67,"watchers":2392,"default_branch":"master"}},"base":{"label":"flynn:master","ref":"master","sha":"1c0d876f643de424e658f14b335e86f388165f3e","user":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=2","gravatar_id":"0f81f5e29cb53c7545c5b77465d9b5c5","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"repo":{"id":11290232,"name":"flynn","full_name":"flynn/flynn","owner":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=2","gravatar_id":"0f81f5e29cb53c7545c5b77465d9b5c5","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flynn/flynn","description":"A next generation open source platform as a service (PaaS)","fork":false,"url":"https://api.github.com/repos/flynn/flynn","forks_url":"https://api.github.com/repos/flynn/flynn/forks","keys_url":"https://api.github.com/repos/flynn/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flynn/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flynn/flynn/teams","hooks_url":"https://api.github.com/repos/flynn/flynn/hooks","issue_events_url":"https://api.github.com/repos/flynn/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/flynn/flynn/events","assignees_url":"https://api.github.com/repos/flynn/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/flynn/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/flynn/flynn/tags","blobs_url":"https://api.github.com/repos/flynn/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flynn/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flynn/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/flynn/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/flynn/flynn/languages","stargazers_url":"https://api.github.com/repos/flynn/flynn/stargazers","contributors_url":"https://api.github.com/repos/flynn/flynn/contributors","subscribers_url":"https://api.github.com/repos/flynn/flynn/subscribers","subscription_url":"https://api.github.com/repos/flynn/flynn/subscription","commits_url":"https://api.github.com/repos/flynn/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/flynn/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/flynn/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/flynn/flynn/issues/comments/{number}","contents_url":"https://api.github.com/repos/flynn/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/flynn/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flynn/flynn/merges","archive_url":"https://api.github.com/repos/flynn/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flynn/flynn/downloads","issues_url":"https://api.github.com/repos/flynn/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/flynn/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/flynn/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/flynn/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flynn/flynn/labels{/name}","releases_url":"https://api.github.com/repos/flynn/flynn/releases{/id}","created_at":"2013-07-09T18:22:06Z","updated_at":"2014-09-12T18:12:41Z","pushed_at":"2014-09-12T19:26:46Z","git_url":"git://github.com/flynn/flynn.git","ssh_url":"git@github.com:flynn/flynn.git","clone_url":"https://github.com/flynn/flynn.git","svn_url":"https://github.com/flynn/flynn","homepage":"https://flynn.io","size":13349,"stargazers_count":2392,"watchers_count":2392,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":119,"mirror_url":null,"open_issues_count":67,"forks":119,"open_issues":67,"watchers":2392,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/191"},"html":{"href":"https://github.com/flynn/flynn/pull/191"},"issue":{"href":"https://api.github.com/repos/flynn/flynn/issues/191"},"comments":{"href":"https://api.github.com/repos/flynn/flynn/issues/191/comments"},"review_comments":{"href":"https://api.github.com/repos/flynn/flynn/pulls/191/comments"},"review_comment":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/flynn/flynn/pulls/191/commits"},"statuses":{"href":"https://api.github.com/repos/flynn/flynn/statuses/64bca7e08d61afedb975ff7cabe0f1b8fb013968"}}}}