Refactor error handling in middleware and clean up template struct comments

- Adjust error handling in the middleware to ensure proper redirection for HTTP status codes 301 and 302.
- Clean up comments in the Template struct for better readability and consistency.
This commit is contained in:
Max 2026-02-15 17:56:54 +08:00
parent 621290d578
commit c7cdfbdfe6
2 changed files with 6 additions and 6 deletions

View file

@ -91,9 +91,9 @@ func withStaticFileServer(c *gin.Context) {
html, code, err := r.Render() html, code, err := r.Render()
if err != nil { if err != nil {
if code == 301 || code == 302 { if code == 301 || code == 302 {
url := err.Error() url := err.Error()
c.Redirect(code, url) c.Redirect(code, url)
c.Done() c.Done()
return return
} }

View file

@ -185,9 +185,9 @@ type Template struct {
GlobalData []byte `json:"-"` GlobalData []byte `json:"-"`
Scripts *TemplateScirpts `json:"scripts,omitempty"` Scripts *TemplateScirpts `json:"scripts,omitempty"`
Translator string `json:"translator,omitempty"` Translator string `json:"translator,omitempty"`
Config *PageSetting `json:"config,omitempty"` // Default page config (guard, api, etc.) Config *PageSetting `json:"config,omitempty"` // Default page config (guard, api, etc.)
BuildScript *Script `json:"-"` // __build.backend.ts / __build.backend.js BuildScript *Script `json:"-"` // __build.backend.ts / __build.backend.js
GlobalScript *Script `json:"-"` // __global.backend.ts / __global.backend.js GlobalScript *Script `json:"-"` // __global.backend.ts / __global.backend.js
} }
// TemplateScirpts is the struct for the template scripts // TemplateScirpts is the struct for the template scripts