{"action":"created","issue":{"url":"https://api.github.com/repos/qiangxue/golang-restful-starter-kit/issues/11","repository_url":"https://api.github.com/repos/qiangxue/golang-restful-starter-kit","labels_url":"https://api.github.com/repos/qiangxue/golang-restful-starter-kit/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/qiangxue/golang-restful-starter-kit/issues/11/comments","events_url":"https://api.github.com/repos/qiangxue/golang-restful-starter-kit/issues/11/events","html_url":"https://github.com/qiangxue/golang-restful-starter-kit/issues/11","id":194317143,"number":11,"title":"How to use router.NotFound() in this template?","user":{"login":"kolkov","id":3740898,"avatar_url":"https://avatars.githubusercontent.com/u/3740898?v=3","gravatar_id":"","url":"https://api.github.com/users/kolkov","html_url":"https://github.com/kolkov","followers_url":"https://api.github.com/users/kolkov/followers","following_url":"https://api.github.com/users/kolkov/following{/other_user}","gists_url":"https://api.github.com/users/kolkov/gists{/gist_id}","starred_url":"https://api.github.com/users/kolkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolkov/subscriptions","organizations_url":"https://api.github.com/users/kolkov/orgs","repos_url":"https://api.github.com/users/kolkov/repos","events_url":"https://api.github.com/users/kolkov/events{/privacy}","received_events_url":"https://api.github.com/users/kolkov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-08T11:54:25Z","updated_at":"2016-12-08T14:15:09Z","closed_at":null,"body":"Hi!\r\nI try to use `router.NotFound(redirectToIndex())` in this template and ozzo-routing newer calls my `redirectToIndex()`\r\n```Go\r\nrouter := routing.New()\r\n\r\n\trouter.To(\"GET,HEAD\", \"/ping\", func(c *routing.Context) error {\r\n\t\tc.Abort()  // skip all other middlewares/handlers\r\n\t\treturn c.Write(\"OK \" + app.Version)\r\n\t})\r\n\r\n\trouter.NotFound(redirectToIndex())\r\n\r\n\trouter.Use(\r\n\t\tapp.Init(logger),\r\n\t\tslash.Remover(http.StatusMovedPermanently),\r\n\t)\r\n\r\n\r\n\trg := router.Group(\"/v1\")\r\n...\r\n```\r\n\r\n```\r\n...\r\nfunc redirectToIndex() routing.Handler {\r\n\treturn func(c *routing.Context) error {\r\n\t\thttp.Redirect(c.Response, c.Request, \"http://dev.in-frame.com/a2/\" + c.Request.RequestURI,\r\n\t\t\thttp.StatusMovedPermanently)\r\n\t\treturn nil\r\n\t}\r\n}\r\n```\r\n\r\n![image](https://cloud.githubusercontent.com/assets/3740898/21009302/f2422c34-bd56-11e6-9e77-d54a7f24326a.png)\r\n\r\n\r\nWhat I do wrong?"},"comment":{"url":"https://api.github.com/repos/qiangxue/golang-restful-starter-kit/issues/comments/265749415","html_url":"https://github.com/qiangxue/golang-restful-starter-kit/issues/11#issuecomment-265749415","issue_url":"https://api.github.com/repos/qiangxue/golang-restful-starter-kit/issues/11","id":265749415,"user":{"login":"kolkov","id":3740898,"avatar_url":"https://avatars.githubusercontent.com/u/3740898?v=3","gravatar_id":"","url":"https://api.github.com/users/kolkov","html_url":"https://github.com/kolkov","followers_url":"https://api.github.com/users/kolkov/followers","following_url":"https://api.github.com/users/kolkov/following{/other_user}","gists_url":"https://api.github.com/users/kolkov/gists{/gist_id}","starred_url":"https://api.github.com/users/kolkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolkov/subscriptions","organizations_url":"https://api.github.com/users/kolkov/orgs","repos_url":"https://api.github.com/users/kolkov/repos","events_url":"https://api.github.com/users/kolkov/events{/privacy}","received_events_url":"https://api.github.com/users/kolkov/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T14:15:09Z","updated_at":"2016-12-08T14:15:09Z","body":"I found a little problem.\r\nI use serve static files in my code\r\n```\r\nlogger.Info(\"Start Serving static files on \" + app.Config.StaticPath)\r\n\r\n\trouter.Get(\"/a2\", file.Content(\"ui/index.html\"))\r\n\r\n\trouter.Get(\"/*\", file.Server(file.PathMap{\r\n\t\t\"/a2/\": \"./ui/\",\r\n\t\t\"/data/img/\": app.Config.ImagePath,\r\n\t\t\"/\": app.Config.StaticPath,\r\n\t}))\r\n\r\n\trouter.NotFound(redirectToIndex())\r\n```\r\n\r\nAnd this function send me a 404 error when file is not located on file system:\r\n```\r\n\t\tif file, err = dir.Open(path); err != nil {\r\n\t\t\tif options.CatchAllFile != \"\" {\r\n\t\t\t\treturn serveFile(c, dir, options.CatchAllFile)\r\n\t\t\t}\r\n\t\t\treturn routing.NewHTTPError(http.StatusNotFound, err.Error())\r\n\t\t}\r\n\t\tdefer file.Close\r\n```\r\n\r\nCan we check if is a path of Angular 2 not a file, then redirect it to our index.html? \r\n\r\nThanks!"}}
{"actor":{"display_login":"kolkov"}}