{"action":"created","issue":{"url":"https://api.github.com/repos/labstack/echo/issues/568","repository_url":"https://api.github.com/repos/labstack/echo","labels_url":"https://api.github.com/repos/labstack/echo/issues/568/labels{/name}","comments_url":"https://api.github.com/repos/labstack/echo/issues/568/comments","events_url":"https://api.github.com/repos/labstack/echo/issues/568/events","html_url":"https://github.com/labstack/echo/issues/568","id":160162753,"number":568,"title":"question: how to pass a pre-allocated Context to Echo.ServeHTTP?","user":{"login":"genez","id":324113,"avatar_url":"https://avatars.githubusercontent.com/u/324113?v=3","gravatar_id":"","url":"https://api.github.com/users/genez","html_url":"https://github.com/genez","followers_url":"https://api.github.com/users/genez/followers","following_url":"https://api.github.com/users/genez/following{/other_user}","gists_url":"https://api.github.com/users/genez/gists{/gist_id}","starred_url":"https://api.github.com/users/genez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genez/subscriptions","organizations_url":"https://api.github.com/users/genez/orgs","repos_url":"https://api.github.com/users/genez/repos","events_url":"https://api.github.com/users/genez/events{/privacy}","received_events_url":"https://api.github.com/users/genez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-06-14T11:56:07Z","updated_at":"2016-06-18T10:37:10Z","closed_at":null,"body":"I am build a multi-subdomain HTTP service following the example using an host map\r\nI would like to pass my datastore object into the context but the ServeHTTP func uses a newly-allocated one so it never goes down to my handler\r\n\r\nIs there any work-around?\r\nShould I use a global datastore object?\r\n\r\nThanks\r\n\r\n```\r\n// Server\r\n\te := echo.New()\r\n\te.Any(\"/*\", func(c echo.Context) (err error) {\r\n\t\treq := c.Request()\r\n\t\tres := c.Response()\r\n\t\thost := hosts[req.Host()]\r\n\r\n\t\tif host == nil {\r\n\t\t\terr = echo.ErrNotFound\r\n\t\t} else {\r\n\t\t\tc.Set(\"DataStore\", persistence.DataStore) <-- HERE IS MY ISSUE\r\n\t\t\thost.Echo.ServeHTTP(req, res)\r\n\t\t}\r\n\r\n\t\treturn err\r\n\t})\r\n\te.Run(standard.New(\":8080\"))\r\n```"},"comment":{"url":"https://api.github.com/repos/labstack/echo/issues/comments/226934762","html_url":"https://github.com/labstack/echo/issues/568#issuecomment-226934762","issue_url":"https://api.github.com/repos/labstack/echo/issues/568","id":226934762,"user":{"login":"genez","id":324113,"avatar_url":"https://avatars.githubusercontent.com/u/324113?v=3","gravatar_id":"","url":"https://api.github.com/users/genez","html_url":"https://github.com/genez","followers_url":"https://api.github.com/users/genez/followers","following_url":"https://api.github.com/users/genez/following{/other_user}","gists_url":"https://api.github.com/users/genez/gists{/gist_id}","starred_url":"https://api.github.com/users/genez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/genez/subscriptions","organizations_url":"https://api.github.com/users/genez/orgs","repos_url":"https://api.github.com/users/genez/repos","events_url":"https://api.github.com/users/genez/events{/privacy}","received_events_url":"https://api.github.com/users/genez/received_events","type":"User","site_admin":false},"created_at":"2016-06-18T10:37:09Z","updated_at":"2016-06-18T10:37:09Z","body":"thank you very much for your help.\r\nI understand that the data store is now available in the custom middleware.\r\n\r\nI still don't understand how I can retrieve my db instance in the handler\r\n\r\nfor example \r\n\r\n> blog.GET(\"/\",` func(c echo.Context) error {\r\n>         **ds := *** GET DB INSTANCE HERE *****\r\n>         return c.String(http.StatusOK, \"Blog\")\r\n>     })\r\n\r\nFor example I want to reply with a JSON that lists all the rows from a table\r\n"}}
{"actor":{"display_login":"genez"}}