errors.go 524 B

123456789101112131415161718192021222324252627282930
  1. package routers
  2. import (
  3. "html/template"
  4. "net/http"
  5. )
  6. var err404tpl = `
  7. <!DOCTYPE html>
  8. <html lang="en">
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  11. <title>{{.Title}}</title>
  12. </head>
  13. <body>
  14. <div id="wrapper">
  15. {{.Title}}
  16. </div>
  17. </body>
  18. </html>
  19. `
  20. // show 404 notfound error.
  21. func notFound(rw http.ResponseWriter, r *http.Request) {
  22. t, _ := template.New("error").Parse(err404tpl)
  23. data := map[string]interface{}{
  24. "Title": http.StatusText(404),
  25. }
  26. t.Execute(rw, data)
  27. }