33 lines
914 B
Go
33 lines
914 B
Go
package sync
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/htmlpage"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
//go:embed template/*
|
|
var embeddedFiles embed.FS
|
|
|
|
var components = [...]string{"header", "map"}
|
|
|
|
func buildTemplate(files ...string) *htmlpage.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 htmlpage.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)
|
|
}
|