{"action":"created","issue":{"url":"https://api.github.com/repos/zenazn/goji/issues/188","repository_url":"https://api.github.com/repos/zenazn/goji","labels_url":"https://api.github.com/repos/zenazn/goji/issues/188/labels{/name}","comments_url":"https://api.github.com/repos/zenazn/goji/issues/188/comments","events_url":"https://api.github.com/repos/zenazn/goji/issues/188/events","html_url":"https://github.com/zenazn/goji/issues/188","id":151529666,"number":188,"title":"Question: per-endpoint middleware","user":{"login":"hasryan","id":1844006,"avatar_url":"https://avatars.githubusercontent.com/u/1844006?v=3","gravatar_id":"","url":"https://api.github.com/users/hasryan","html_url":"https://github.com/hasryan","followers_url":"https://api.github.com/users/hasryan/followers","following_url":"https://api.github.com/users/hasryan/following{/other_user}","gists_url":"https://api.github.com/users/hasryan/gists{/gist_id}","starred_url":"https://api.github.com/users/hasryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasryan/subscriptions","organizations_url":"https://api.github.com/users/hasryan/orgs","repos_url":"https://api.github.com/users/hasryan/repos","events_url":"https://api.github.com/users/hasryan/events{/privacy}","received_events_url":"https://api.github.com/users/hasryan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-28T01:39:25Z","updated_at":"2016-05-09T17:29:04Z","closed_at":"2016-05-09T17:29:04Z","body":"I have a question that is similar to https://github.com/zenazn/goji/issues/175 but I'm not sure it's exactly the same use case and would appreciate an opinion on my example below.\r\n\r\nI am building an API and have some endpoints that require different middleware.  The problem is that many of these endpoints are siblings, or have the same path but use a different verb, and are generally organized in ways that I can't apply the same middleware to a common prefix such as `/admin/*`.\r\n\r\nFor example, I need one series of middleware to be applied for requests to `POST /foo/bar` and another, different collection of middleware to be applied for `GET /foo/bar`.  And yet another, distinct collection of middleware applies for `DELETE /foo`.  I basically need the flexibility to apply a unique set of middleware to any given method+pattern combination.\r\n\r\nThe following appears to work, but it's not intuitive to me (providing sub-Muxes to the root Mux as if they were Handler functions, since `*Mux` implements that interface) and I would like to know if this is considered a reasonable way to solve my problem or if it's a hack.  If this isn't a reasonable way to solve it, is there another method I can use to achieve my goal?\r\n\r\n```\r\ngetFooBarMux := web.New()\r\ngetFooBarMux.Use(getFooBarMiddleware)\r\ngetFooBarMux.Get(\"/foo/bar\", getFooBarHandler)\r\n\r\npostFooBarMux := web.New()\r\npostFooBarMux.Use(postFooBarMiddleware)\r\npostfooBarMux.Post(postFooBarHandler)\r\n\r\ndeleteFooMux := web.New()\r\ndeleteFooMux.Use(deleteFooMiddleware)\r\ndeleteFooMux.Delete(deleteFooHandler)\r\n\r\nrootMux := web.New()\r\nrootMux.Get(\"/foo/bar\", getFooBarMux)\r\nrootMux.Post(\"/foo/bar\", postFooBarMux)\r\nrootMux.Delete(\"/foo\", deleteFooMux)\r\n```"},"comment":{"url":"https://api.github.com/repos/zenazn/goji/issues/comments/217931592","html_url":"https://github.com/zenazn/goji/issues/188#issuecomment-217931592","issue_url":"https://api.github.com/repos/zenazn/goji/issues/188","id":217931592,"user":{"login":"hasryan","id":1844006,"avatar_url":"https://avatars.githubusercontent.com/u/1844006?v=3","gravatar_id":"","url":"https://api.github.com/users/hasryan","html_url":"https://github.com/hasryan","followers_url":"https://api.github.com/users/hasryan/followers","following_url":"https://api.github.com/users/hasryan/following{/other_user}","gists_url":"https://api.github.com/users/hasryan/gists{/gist_id}","starred_url":"https://api.github.com/users/hasryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasryan/subscriptions","organizations_url":"https://api.github.com/users/hasryan/orgs","repos_url":"https://api.github.com/users/hasryan/repos","events_url":"https://api.github.com/users/hasryan/events{/privacy}","received_events_url":"https://api.github.com/users/hasryan/received_events","type":"User","site_admin":false},"created_at":"2016-05-09T17:29:04Z","updated_at":"2016-05-09T17:29:04Z","body":"Thank you, this is very helpful!"}}