diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-06 09:58:02 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-06 09:58:02 +0800 |
commit | 6f5e22e764283262ae8c6519bb030766db0fd35b (patch) | |
tree | c56038bd7b5dc31d5bae5dd6e323688725c5262e /forged/internal/web | |
parent | Fix load ordering issue that causes the forge title to disappear (diff) | |
download | forge-6f5e22e764283262ae8c6519bb030766db0fd35b.tar.gz forge-6f5e22e764283262ae8c6519bb030766db0fd35b.tar.zst forge-6f5e22e764283262ae8c6519bb030766db0fd35b.zip |
Add more documentation comments
Diffstat (limited to 'forged/internal/web')
-rw-r--r-- | forged/internal/web/error_pages.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/forged/internal/web/error_pages.go b/forged/internal/web/error_pages.go index 200e9d3..2ba9a1a 100644 --- a/forged/internal/web/error_pages.go +++ b/forged/internal/web/error_pages.go @@ -8,40 +8,52 @@ import ( "net/http" ) +// ErrorPage404 renders a 404 Not Found error page using the "404" template. func ErrorPage404(templates *template.Template, w http.ResponseWriter, params map[string]any) { w.WriteHeader(http.StatusNotFound) _ = templates.ExecuteTemplate(w, "404", params) } +// ErrorPage400 renders a 400 Bad Request error page using the "400" template. +// The error message is passed via the "complete_error_msg" template param. func ErrorPage400(templates *template.Template, w http.ResponseWriter, params map[string]any, msg string) { w.WriteHeader(http.StatusBadRequest) params["complete_error_msg"] = msg _ = templates.ExecuteTemplate(w, "400", params) } +// ErrorPage400Colon renders a 400 Bad Request error page telling the user +// that we migrated from : to -. func ErrorPage400Colon(templates *template.Template, w http.ResponseWriter, params map[string]any) { w.WriteHeader(http.StatusBadRequest) _ = templates.ExecuteTemplate(w, "400_colon", params) } +// ErrorPage403 renders a 403 Forbidden error page using the "403" template. +// The error message is passed via the "complete_error_msg" template param. func ErrorPage403(templates *template.Template, w http.ResponseWriter, params map[string]any, msg string) { w.WriteHeader(http.StatusForbidden) params["complete_error_msg"] = msg _ = templates.ExecuteTemplate(w, "403", params) } +// ErrorPage451 renders a 451 Unavailable For Legal Reasons error page using the "451" template. +// The error message is passed via the "complete_error_msg" template param. func ErrorPage451(templates *template.Template, w http.ResponseWriter, params map[string]any, msg string) { w.WriteHeader(http.StatusUnavailableForLegalReasons) params["complete_error_msg"] = msg _ = templates.ExecuteTemplate(w, "451", params) } +// ErrorPage500 renders a 500 Internal Server Error page using the "500" template. +// The error message is passed via the "complete_error_msg" template param. func ErrorPage500(templates *template.Template, w http.ResponseWriter, params map[string]any, msg string) { w.WriteHeader(http.StatusInternalServerError) params["complete_error_msg"] = msg _ = templates.ExecuteTemplate(w, "500", params) } +// ErrorPage501 renders a 501 Not Implemented error page using the "501" template. func ErrorPage501(templates *template.Template, w http.ResponseWriter, params map[string]any) { w.WriteHeader(http.StatusNotImplemented) _ = templates.ExecuteTemplate(w, "501", params) |