{"action":"created","issue":{"url":"https://api.github.com/repos/gocraft/web/issues/43","labels_url":"https://api.github.com/repos/gocraft/web/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/gocraft/web/issues/43/comments","events_url":"https://api.github.com/repos/gocraft/web/issues/43/events","html_url":"https://github.com/gocraft/web/issues/43","id":56589305,"number":43,"title":"Method Contexts via route reflect does not support pointers in said Context","user":{"login":"bundah","id":3374513,"avatar_url":"https://avatars.githubusercontent.com/u/3374513?v=3","gravatar_id":"","url":"https://api.github.com/users/bundah","html_url":"https://github.com/bundah","followers_url":"https://api.github.com/users/bundah/followers","following_url":"https://api.github.com/users/bundah/following{/other_user}","gists_url":"https://api.github.com/users/bundah/gists{/gist_id}","starred_url":"https://api.github.com/users/bundah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundah/subscriptions","organizations_url":"https://api.github.com/users/bundah/orgs","repos_url":"https://api.github.com/users/bundah/repos","events_url":"https://api.github.com/users/bundah/events{/privacy}","received_events_url":"https://api.github.com/users/bundah/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-04T21:21:24Z","updated_at":"2015-02-05T17:21:37Z","closed_at":"2015-02-05T17:21:37Z","body":"Here is a snippet of a continuation of the nested routers and use of pointers with Context example from the docs:\r\nhttps://gist.github.com/bundah/d29cfc5fed6a6cb8428c\r\n\r\nRemoving the struct pointer for User and following same pattern in web.New yields less crash but still incorrect behaviour:\r\n```\r\nadminRouter := rootRouter.Subrouter(AdminContext{CurrentAdmin: User{Name: \"Bill\"}}, \"/admin\") // and also change the struct\r\n```\r\n\r\nAnd finally, if we change these bits to:\r\n```\r\ntype AdminContext struct {\r\n    *Context\r\n    CurrentAdmin User\r\n}\r\n\r\nactx := AdminContext{CurrentAdmin: User{Name: \"Bill\"}}\r\nadminRouter := rootRouter.Subrouter(actx, \"/admin\")\r\n    adminRouter.Get(\"/reports\", (actx).Reports) //(*AdminContext).Reports)\r\n\r\n```\r\n\r\nand curl that one, the name prints... Except that all requests now share actx instance and changing anywere at runtime via middleware etc crosses the request boundary (and can poison other requests).\r\n\r\n\r\nPlease advise...\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/gocraft/web/issues/comments/73087279","html_url":"https://github.com/gocraft/web/issues/43#issuecomment-73087279","issue_url":"https://api.github.com/repos/gocraft/web/issues/43","id":73087279,"user":{"login":"bundah","id":3374513,"avatar_url":"https://avatars.githubusercontent.com/u/3374513?v=3","gravatar_id":"","url":"https://api.github.com/users/bundah","html_url":"https://github.com/bundah","followers_url":"https://api.github.com/users/bundah/followers","following_url":"https://api.github.com/users/bundah/following{/other_user}","gists_url":"https://api.github.com/users/bundah/gists{/gist_id}","starred_url":"https://api.github.com/users/bundah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundah/subscriptions","organizations_url":"https://api.github.com/users/bundah/orgs","repos_url":"https://api.github.com/users/bundah/repos","events_url":"https://api.github.com/users/bundah/events{/privacy}","received_events_url":"https://api.github.com/users/bundah/received_events","type":"User","site_admin":false},"created_at":"2015-02-05T17:21:37Z","updated_at":"2015-02-05T17:21:37Z","body":"Thanks for the response and fixed the markdowns... the example issue(s) and progression of was actually the reverse in how I began using gocraft.  I was doing it very very wrong at first setting/defining the root router and handler contexts with an instantiated context struct which had static configuration data (below is an oversimplified example of how I was incorrectly using it).\r\n```\r\ntype Context struct {\r\n  Config *CFG\r\n  Token *AuthToken\r\n}\r\n\r\nctx := { Config: &CFG{}, Token: nil}\r\n\r\nroute := web.New(ctx)\r\nroute.Get(\"/\", ctx.SlashHandler)\r\n```\r\n\r\nThen when the context was modified in middleware (oauth) the issue(s) became more evident as it was the exact same *context being passed around and there were collisions at runtime when auth tokens were gleaned from headers...  This was eventually resolved by not passing struct values into handlers AND following a similar solution as:\r\n\r\nhttps://github.com/gocraft/web/issues/38\r\n\r\n...where middleware uses a closure to populate said context struct w/ the static data (Config) and another middleware is used to fill dynamic value (Auth tokens) on the copied context type passed in by gocrafts middlware invoke.\r\n\r\nI guess the takeway is I received an ID-10-T error and at a minimum at least these two \"issues\" (38 and this) may help others to not make the same mistake."}}