| 99 | </html>` |
| 100 | |
| 101 | func indexHandler(httpPathPrefix string, content *IndexPageContent) http.HandlerFunc { |
| 102 | templ := template.New("main") |
| 103 | templ.Funcs(map[string]any{ |
| 104 | "AddPathPrefix": func(link string) string { |
| 105 | return path.Join(httpPathPrefix, link) |
| 106 | }, |
| 107 | }) |
| 108 | template.Must(templ.Parse(indexPageTemplate)) |
| 109 | |
| 110 | return func(w http.ResponseWriter, r *http.Request) { |
| 111 | err := templ.Execute(w, content.GetContent()) |
| 112 | if err != nil { |
| 113 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func (cfg *Config) configHandler(actualCfg any, defaultCfg any) http.HandlerFunc { |
| 119 | if cfg.CustomConfigHandler != nil { |