diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 18:36:06 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-02 18:36:06 +0200 |
| commit | 49766901293631aeabfc96e8d80aba305f420630 (patch) | |
| tree | 56ada5226ac5d47a8277de00022190ab946490a1 /backend/data.go | |
| parent | 1168ac60d3a22c0d354f291fd657ad302df6ec05 (diff) | |
feat(backend): config to set domain
Diffstat (limited to 'backend/data.go')
| -rw-r--r-- | backend/data.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/backend/data.go b/backend/data.go index bc74ba5..3bc93d1 100644 --- a/backend/data.go +++ b/backend/data.go @@ -4,6 +4,7 @@ import ( "fmt" "html/template" "net/http" + "strings" ) type data struct { @@ -15,7 +16,14 @@ type data struct { Description string } -func (d *data) handleGeneric(w http.ResponseWriter, name string) { +func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string) { + if d.Domain == "" { + cfg := r.Context().Value("config").(*Config) + d.Domain = cfg.Domain + } + if d.URL == "" { + d.URL = strings.TrimPrefix(r.URL.Path, "/") + } t, err := template.New("").Funcs(template.FuncMap{ "static": func(path string) string { return fmt.Sprintf("/static/%s", path) |
