GitHub PullRequestReviewCommentEvent at 2014-04-26 18:08:55
Repository: revel
Actor: brendensoares
Payload: {"comment":{"url":"https://api.github.com/repos/revel/revel/pulls/comments/12025569","id":12025569,"diff_hunk":"@@ -464,3 +464,39 @@ func RouterFilter(c *Controller, fc []Filter) {\n \n \tfc[0](c, fc[1:])\n }\n+\n+// Override allowed http methods via form or browser param\n+func HttpMethodOverride(c *Controller, fc []Filter) {\n+\t// An array of HTTP verbs allowed.\n+\tverbs := []string{\"POST\", \"PUT\", \"PATCH\", \"DELETE\"}\n+\n+\tmethod := strings.ToUpper(c.Request.Request.Method)\n+\n+\tif method == \"POST\" {\n+\n+\t\tparam := strings.ToUpper(c.Request.Request.PostFormValue(\"_method\"))\n+\n+\t\tif len(param) > 0 {\n+\t\t\toverride := false\n+\t\t\t// Check if param is allowed\n+\t\t\tfor _, verb := range verbs {\n+\t\t\t\tif verb == param {\n+\t\t\t\t\toverride = true\n+\t\t\t\t\tbreak\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tif !override {\n+\t\t\t\tc.Response.Status = 405\n+\t\t\t\treturn c.RenderError(&Error{\n+\t\t\t\t\tTitle:       \"Method not allowed\",\n+\t\t\t\t\tDescription: \"\",\n+\t\t\t\t})\n+\t\t\t}\n+\n+\t\t\tc.Request.Request.Method = param","path":"router.go","position":34,"original_position":34,"commit_id":"5e721e4abb9e4415da1fb20da732585d166a221f","original_commit_id":"5e721e4abb9e4415da1fb20da732585d166a221f","user":{"login":"brendensoares","id":905501,"avatar_url":"https://avatars.githubusercontent.com/u/905501?","gravatar_id":"7cda9bd33304b647bb27408979d34c8b","url":"https://api.github.com/users/brendensoares","html_url":"https://github.com/brendensoares","followers_url":"https://api.github.com/users/brendensoares/followers","following_url":"https://api.github.com/users/brendensoares/following{/other_user}","gists_url":"https://api.github.com/users/brendensoares/gists{/gist_id}","starred_url":"https://api.github.com/users/brendensoares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendensoares/subscriptions","organizations_url":"https://api.github.com/users/brendensoares/orgs","repos_url":"https://api.github.com/users/brendensoares/repos","events_url":"https://api.github.com/users/brendensoares/events{/privacy}","received_events_url":"https://api.github.com/users/brendensoares/received_events","type":"User","site_admin":false},"body":"Perhaps make this part of the `else` condition of the above `if`?","created_at":"2014-04-26T18:08:55Z","updated_at":"2014-04-26T18:08:55Z","html_url":"https://github.com/revel/revel/pull/583#discussion_r12025569","pull_request_url":"https://api.github.com/repos/revel/revel/pulls/583","_links":{"self":{"href":"https://api.github.com/repos/revel/revel/pulls/comments/12025569"},"html":{"href":"https://github.com/revel/revel/pull/583#discussion_r12025569"},"pull_request":{"href":"https://api.github.com/repos/revel/revel/pulls/583"}}}}