Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the NotFoundHandler when a file haven't been found. (labstack#966)
This is especialy usefull when you use e.Static("/", "static") and you want a notfoundhandler that serves your index.html like this: echo.NotFoundHandler = func(c2 echo.Context) error { index := filepath.Join(c.config.StaticDir, c.config.Index) _, err := os.Open(index) if err != nil { return echo.ErrNotFound } return c2.File(path.Join(c.config.StaticDir, c.config.Index)) } Another usecase with the Handler above is HTML5 SPF applications. One caveat, you need to make sure that your NotFoundHandler doesn't produce loops. Signed-off-by: Rene Jochum <[email protected]>
- Loading branch information