Lindenii Project Forge
Login

server

Lindenii Forge’s main backend daemon
Commit info
ID
088325073247e2f7bc85fd3baafdad1ea6a635a5
Author
Runxi Yu <me@runxiyu.org>
Author date
Sat, 22 Mar 2025 11:53:04 +0800
Committer
Runxi Yu <me@runxiyu.org>
Committer date
Sat, 22 Mar 2025 11:53:04 +0800
Actions
Add HTTP 451
// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileContributor: Runxi Yu <https://runxiyu.org>

package main

import (
	"net/http"
)

func errorPage404(w http.ResponseWriter, params map[string]any) {
	w.WriteHeader(404)
	_ = templates.ExecuteTemplate(w, "404", params)
}

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)
}
{{/*
	SPDX-License-Identifier: AGPL-3.0-only
	SPDX-FileContributor: Runxi Yu <https://runxiyu.org>
*/}}
{{- define "400" -}}
<!DOCTYPE html>
<html lang="en">
	<head>
		{{- template "head_common" . -}}
		<title>400 Bad Request &ndash; {{ .global.forge_title }}</title>
	</head>
	<body class="400">
		{{- template "header" . -}}
		<div class="padding-wrapper complete-error-page">
			<h1>400 Bad Request</h1>
			<p>{{- .bad_request_msg -}}</p>
			<p>{{- .complete_error_msg -}}</p>
			<hr />
			<address>Lindenii Forge</address>
		</div>
		<footer>
			{{- template "footer" . -}}
		</footer>
	</body>
</html>
{{- end -}}
{{/*
	SPDX-License-Identifier: AGPL-3.0-only
	SPDX-FileContributor: Runxi Yu <https://runxiyu.org>
*/}}
{{- define "451" -}}
<!DOCTYPE html>
<html lang="en">
	<head>
		{{- template "head_common" . -}}
		<title>451 Unavailable For Legal Reasons &ndash; {{ .global.forge_title }}</title>
	</head>
	<body class="451">
		{{- template "header" . -}}
		<div class="padding-wrapper complete-error-page">
			<h1>451 Unavailable For Legal Reasons</h1>
			<p>{{- .complete_error_msg -}}</p>
			<hr />
			<address>Lindenii Forge</address>
		</div>
		<footer>
			{{- template "footer" . -}}
		</footer>
	</body>
</html>
{{- end -}}