剔除更多的模板变量

This commit is contained in:
ExplodingDragon
2025-04-15 21:04:25 +08:00
parent 036569ac5f
commit bdd432fd80
2 changed files with 7 additions and 8 deletions

View File

@@ -12,6 +12,6 @@
{{ if eq .Code 404 }}<h1>404 Not Found</h1>{{ else }}<h1>500 Unknown Error</h1>{{ end }} {{ if eq .Code 404 }}<h1>404 Not Found</h1>{{ else }}<h1>500 Unknown Error</h1>{{ end }}
</div> </div>
<hr> <hr>
<div style="text-align: center;">Gitea Pages/{{ .UUID }}</div> <div style="text-align: center;">Gitea Pages({{.Request.Host}})/{{ .UUID }}</div>
</Body> </Body>
</html> </html>

View File

@@ -13,15 +13,14 @@ func NewTemplateInject(r *http.Request, def map[string]any) map[string]any {
def = make(map[string]any) def = make(map[string]any)
} }
headers := make(map[string]string) headers := make(map[string]string)
for k, vs := range r.Header { for k, vs := range r.Header.Clone() {
headers[k] = strings.Join(vs, ",") headers[k] = strings.Join(vs, ",")
} }
def["Request"] = map[string]any{ def["Request"] = map[string]any{
"Headers": headers, "Host": r.Host,
"Path": r.URL.Path, "Path": r.URL.Path,
"Params": r.URL.Query(),
"Method": r.Method, "Method": r.Method,
"RequestURI": r.RequestURI,
"RemoteAddr": r.RemoteAddr,
"RemoteIP": GetRemoteIP(r), "RemoteIP": GetRemoteIP(r),
} }
return def return def