website/pkg/templates/error_pages.go
Noah cd1b349fcc User Photo Gallery & Management
* Add the user photo gallery for profile pages. Paginated, grid or full (blog
  style) view options. In grid view clicking a photo opens a large modal to
  see it; full view already shows large photos.
* Edit page: can also re-crop and set an existing pic to be your profile pic.
* Delete page: remove photos from the DB and hard drive.
* Photos are cleaned up from disk when not needed, e.g. during a re-crop the
  old cropped photo is removed before the new one replaces it.
* Fixed bug with cropping pictures.
2022-08-12 23:11:36 -07:00

30 lines
864 B
Go

package templates
import (
"net/http"
)
// NotFoundPage is an HTTP handler for 404 pages.
var NotFoundPage = func() http.HandlerFunc {
return MakeErrorPage("Not Found", "The page you requested was not here.", http.StatusNotFound)
}()
// ForbiddenPage is an HTTP handler for 404 pages.
var ForbiddenPage = func() http.HandlerFunc {
return MakeErrorPage("Forbidden", "You do not have permission for this page.", http.StatusForbidden)
}()
func MakeErrorPage(header string, message string, statusCode int) http.HandlerFunc {
tmpl := Must("errors/error.html")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(statusCode)
if err := tmpl.Execute(w, r, map[string]interface{}{
"Header": header,
"Message": message,
}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
})
}