{"action":"opened","issue":{"url":"https://api.github.com/repos/gocraft/web/issues/48","labels_url":"https://api.github.com/repos/gocraft/web/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/gocraft/web/issues/48/comments","events_url":"https://api.github.com/repos/gocraft/web/issues/48/events","html_url":"https://github.com/gocraft/web/issues/48","id":93414863,"number":48,"title":"Accessing the Main Context From Subroute","user":{"login":"samphomsopha","id":4575779,"avatar_url":"https://avatars.githubusercontent.com/u/4575779?v=3","gravatar_id":"","url":"https://api.github.com/users/samphomsopha","html_url":"https://github.com/samphomsopha","followers_url":"https://api.github.com/users/samphomsopha/followers","following_url":"https://api.github.com/users/samphomsopha/following{/other_user}","gists_url":"https://api.github.com/users/samphomsopha/gists{/gist_id}","starred_url":"https://api.github.com/users/samphomsopha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samphomsopha/subscriptions","organizations_url":"https://api.github.com/users/samphomsopha/orgs","repos_url":"https://api.github.com/users/samphomsopha/repos","events_url":"https://api.github.com/users/samphomsopha/events{/privacy}","received_events_url":"https://api.github.com/users/samphomsopha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-07T01:34:03Z","updated_at":"2015-07-07T01:34:03Z","closed_at":null,"body":"Hi,\r\nHow do I access the root context from my subroute? For example, if I have a Session defined in Context, how do I access from /admin/index? \r\nAccessing \"Session\" causes a **\"runtime error: invalid memory address or nil pointer dereference\"**\r\nSee code below.\r\n\r\n### Context\r\n```\r\ntype Context struct {\r\n    Session map[string]string\r\n}\r\n\r\ntype AdminContext struct {\r\n    *Context\r\n    CurrentAdmin *User\r\n}\r\n```\r\n### Route Handler\r\n```\r\nfunc (ac *AdminContext) Index(rw web.ResponseWriter, req *web.Request) {\r\n    fmt.Println(ac.Session[\"key\"]); //runtime error: invalid memory address or nil pointer dereference\r\n}\r\n```\r\n\r\n### Server.go\r\n```\r\nrootRouter := web.New(Context{})\r\nadminRouter := rootRouter.Subrouter(AdminContext{}, \"/admin\")\r\nadminRouter.Get(\"/reports\", (*AdminContext).Index)\r\n```\r\n"}}