From bdd432fd80935111f5dc4942a60516c064cb8d21 Mon Sep 17 00:00:00 2001 From: ExplodingDragon Date: Tue, 15 Apr 2025 21:04:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=94=E9=99=A4=E6=9B=B4=E5=A4=9A=E7=9A=84?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- errors.html.tmpl | 2 +- pkg/utils/template.go | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/errors.html.tmpl b/errors.html.tmpl index 566ee4d..8a3a10a 100644 --- a/errors.html.tmpl +++ b/errors.html.tmpl @@ -12,6 +12,6 @@ {{ if eq .Code 404 }}

404 Not Found

{{ else }}

500 Unknown Error

{{ end }}
-
Gitea Pages/{{ .UUID }}
+
Gitea Pages({{.Request.Host}})/{{ .UUID }}
\ No newline at end of file diff --git a/pkg/utils/template.go b/pkg/utils/template.go index 95690fa..4a05a90 100644 --- a/pkg/utils/template.go +++ b/pkg/utils/template.go @@ -13,16 +13,15 @@ func NewTemplateInject(r *http.Request, def map[string]any) map[string]any { def = make(map[string]any) } headers := make(map[string]string) - for k, vs := range r.Header { + for k, vs := range r.Header.Clone() { headers[k] = strings.Join(vs, ",") } def["Request"] = map[string]any{ - "Headers": headers, - "Path": r.URL.Path, - "Method": r.Method, - "RequestURI": r.RequestURI, - "RemoteAddr": r.RemoteAddr, - "RemoteIP": GetRemoteIP(r), + "Host": r.Host, + "Path": r.URL.Path, + "Params": r.URL.Query(), + "Method": r.Method, + "RemoteIP": GetRemoteIP(r), } return def }