From 088325073247e2f7bc85fd3baafdad1ea6a635a5 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 22 Mar 2025 11:53:04 +0800 Subject: [PATCH] Add HTTP 451 --- http_error_page.go | 8 +++++++- templates/400.tmpl | 2 +- templates/451.tmpl | 25 +++++++++++++++++++++++++ diff --git a/http_error_page.go b/http_error_page.go index 39807974aced11f322cf1e7138c7ead681cc700e..cb9e6ed7429d155829663a08e15cc6dde934245b 100644 --- a/http_error_page.go +++ b/http_error_page.go @@ -14,6 +14,12 @@ } func errorPage400(w http.ResponseWriter, params map[string]any, msg string) { w.WriteHeader(400) - params["bad_request_msg"] = msg + params["complete_error_msg"] = msg _ = templates.ExecuteTemplate(w, "400", params) } + +func errorPage451(w http.ResponseWriter, params map[string]any, msg string) { + w.WriteHeader(451) + params["complete_error_msg"] = msg + _ = templates.ExecuteTemplate(w, "451", params) +} diff --git a/templates/400.tmpl b/templates/400.tmpl index 1fcd5d919d72c25f81e876b68567798f36f8a172..d141ed507d4183faef9aefbf6a87c49b33c2c6a1 100644 --- a/templates/400.tmpl +++ b/templates/400.tmpl @@ -13,7 +13,7 @@ {{- template "header" . -}}

400 Bad Request

-

{{- .bad_request_msg -}}

+

{{- .complete_error_msg -}}


Lindenii Forge
diff --git a/templates/451.tmpl b/templates/451.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..114fde668fefe3c7ea6500b98f9441059ec9a30a --- /dev/null +++ b/templates/451.tmpl @@ -0,0 +1,25 @@ +{{/* + SPDX-License-Identifier: AGPL-3.0-only + SPDX-FileContributor: Runxi Yu +*/}} +{{- define "451" -}} + + + + {{- template "head_common" . -}} + 451 Unavailable For Legal Reasons – {{ .global.forge_title }} + + + {{- template "header" . -}} +
+

451 Unavailable For Legal Reasons

+

{{- .complete_error_msg -}}

+
+
Lindenii Forge
+
+ + + +{{- end -}} -- 2.48.1