nidus-sync/sync/page.go
Eli Ribble 9b1d75d47f
Rename htmlpage to html
Because it's going to get more tools.
2026-01-30 19:32:01 +00:00

33 lines
922 B
Go

package sync
import (
"embed"
"fmt"
"net/http"
"github.com/Gleipnir-Technology/nidus-sync/html"
"github.com/rs/zerolog/log"
)
//go:embed template/*
var embeddedFiles embed.FS
var components = [...]string{"header", "icons", "map", "sidebar"}
func buildTemplate(files ...string) *html.BuiltTemplate {
subdir := "sync"
full_files := make([]string, 0)
for _, f := range files {
full_files = append(full_files, fmt.Sprintf("%s/template/%s.html", subdir, f))
}
for _, c := range components {
full_files = append(full_files, fmt.Sprintf("%s/template/components/%s.html", subdir, c))
}
return html.NewBuiltTemplate(embeddedFiles, "sync/", full_files...)
}
// Respond with an error that is visible to the user
func respondError(w http.ResponseWriter, m string, e error, s int) {
log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error from sync pages")
http.Error(w, m, s)
}