Cleaned up middleware/route handlers

This commit is contained in:
2025-02-22 20:34:09 +11:00
parent 0a3796914f
commit f34c1c11aa
18 changed files with 58 additions and 96 deletions

24
handler/errorpage.go Normal file
View File

@@ -0,0 +1,24 @@
package handler
import (
"net/http"
"projectreshoot/view/page"
)
func ErrorPage(
errorCode int,
w http.ResponseWriter,
r *http.Request,
) {
message := map[int]string{
401: "You need to login to view this page.",
403: "You do not have permission to view this page.",
404: "The page or resource you have requested does not exist.",
500: `An error occured on the server. Please try again, and if this
continues to happen contact an administrator.`,
503: "The server is currently down for maintenance and should be back soon. =)",
}
w.WriteHeader(http.StatusUnauthorized)
page.Error(errorCode, http.StatusText(errorCode), message[errorCode]).
Render(r.Context(), w)
}