1
0
mirror of https://github.com/labstack/echo.git synced 2025-02-05 13:15:02 +02:00
Rene Jochum 0769b34b52 Use the NotFoundHandler when a file haven't been found. (#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 <rene@jochums.at>
2017-07-19 11:29:41 -07:00
2017-06-22 11:27:49 -07:00
2017-07-14 11:55:19 -07:00
2016-11-16 21:26:56 -08:00
2017-01-17 10:47:16 -08:00
2017-06-28 19:08:45 -07:00
2017-06-03 21:23:15 -07:00
2017-01-09 20:20:51 -08:00
2016-12-15 11:08:56 -08:00
2017-06-28 19:08:45 -07:00
2017-06-28 17:01:48 -07:00
2017-06-14 16:30:53 -07:00
2017-06-07 08:57:31 -07:00
2017-06-07 08:57:31 -07:00

Sourcegraph GoDoc Go Report Card Build Status Codecov Forum Twitter License

Feature Overview

  • Optimized HTTP router which smartly prioritize routes
  • Build robust and scalable RESTful APIs
  • Group APIs
  • Extensible middleware framework
  • Define middleware at root, group or route level
  • Data binding for JSON, XML and form payload
  • Handy functions to send variety of HTTP responses
  • Centralized HTTP error handling
  • Template rendering with any template engine
  • Define your format for the logger
  • Highly customizable
  • Automatic TLS via Let’s Encrypt
  • HTTP/2 support

Performance

Performance

Get Started

Support Us

Contribute

Use issues for everything

  • For a small change, just send a PR.
  • For bigger changes open an issue for discussion before sending a PR.
  • PR should have:
    • Test case
    • Documentation
    • Example (If it makes sense)
  • You can also contribute by:
    • Reporting issues
    • Suggesting new features or enhancements
    • Improve/fix documentation

Credits

License

MIT

Languages
Go 99.9%
Makefile 0.1%