{"action":"opened","issue":{"url":"https://api.github.com/repos/gin-gonic/gin/issues/691","repository_url":"https://api.github.com/repos/gin-gonic/gin","labels_url":"https://api.github.com/repos/gin-gonic/gin/issues/691/labels{/name}","comments_url":"https://api.github.com/repos/gin-gonic/gin/issues/691/comments","events_url":"https://api.github.com/repos/gin-gonic/gin/issues/691/events","html_url":"https://github.com/gin-gonic/gin/issues/691","id":173689273,"number":691,"title":"Group middleware cannot be effect for the invaid request method","user":{"login":"eaglewu","id":3753615,"avatar_url":"https://avatars.githubusercontent.com/u/3753615?v=3","gravatar_id":"","url":"https://api.github.com/users/eaglewu","html_url":"https://github.com/eaglewu","followers_url":"https://api.github.com/users/eaglewu/followers","following_url":"https://api.github.com/users/eaglewu/following{/other_user}","gists_url":"https://api.github.com/users/eaglewu/gists{/gist_id}","starred_url":"https://api.github.com/users/eaglewu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eaglewu/subscriptions","organizations_url":"https://api.github.com/users/eaglewu/orgs","repos_url":"https://api.github.com/users/eaglewu/repos","events_url":"https://api.github.com/users/eaglewu/events{/privacy}","received_events_url":"https://api.github.com/users/eaglewu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-29T03:23:23Z","updated_at":"2016-08-29T03:23:23Z","closed_at":null,"body":"```go\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"github.com/gin-gonic/gin\"\r\n)\r\n\r\nfunc main() {\r\n\r\n\tr := gin.New()\r\n\r\n\t// Global middleware\r\n\tr.Use(gin.Logger())\r\n\tr.Use(gin.Recovery())\r\n\r\n\t// All request always use the middleware\r\n\tr.Use(func(c *gin.Context) {\r\n\t\tfmt.Println(\"Global middleware passed\")\r\n\t})\r\n\r\n\tv2 := r.Group(\"/v2/\")\r\n\r\n\t// Only the right request method can be use the middleware\r\n\tv2.Use(MiddlewareV2)\r\n\t{\r\n\t\tv2.GET(\"/normal\", normal)\r\n\t}\r\n\r\n\tr.Run(\":8080\")\r\n}\r\n\r\nfunc MiddlewareV2(c *gin.Context) {\r\n\tfmt.Println(\"Group middleware passed\")\r\n\tc.AbortWithStatus(503) //just test\r\n\treturn\r\n}\r\n\r\nfunc normal(c *gin.Context) {\r\n\tc.String(200, \"OK\")\r\n}\r\n\r\n```\r\n\r\n\r\nTest\r\n\r\n```sell\r\n#right method\r\n$ curl -XGET http://127.0.0.1:8080/v2/normal\r\n```\r\n```shell\r\n# Log\r\nGlobal middleware passed\r\nGroup middleware passed\r\n[GIN] 2016/08/29 - 11:11:31 | 503 |      61.649µs | 127.0.0.1 |   GET     /v2/normal\r\n```\r\n\r\n```shell\r\n# invalid method\r\n$ curl -XOPTIONS http://127.0.0.1:8080/v2/normal\r\n```\r\n```shell\r\n# Log\r\nGlobal middleware passed\r\n[GIN] 2016/08/29 - 11:11:44 | 404 |      43.675µs | 127.0.0.1 |   OPTIONS /v2/normal\r\n```\r\n\r\nThe above show that  global middleware can be effect when use invalid method. \r\nBut the group middleware must the right method can be effect.  \r\n\r\nIF not an issue, please tell me how to do it?\r\n\r\nThanks."}}
{"actor":{"display_login":"eaglewu"}}