|
@@ -68,10 +68,7 @@ func MakeRouteContacts() http.HandlerFunc {
|
|
if search != "" {
|
|
if search != "" {
|
|
contactsSet = (&Contact{}).Search(search)
|
|
contactsSet = (&Contact{}).Search(search)
|
|
if r.Header.Get("HX-Trigger") == "search" {
|
|
if r.Header.Get("HX-Trigger") == "search" {
|
|
- MakeTemplate(
|
|
|
|
- "layout",
|
|
|
|
- "rows",
|
|
|
|
- ).Execute(w, anyMap{"contacts": contactsSet})
|
|
|
|
|
|
+ tpl.Execute(w, anyMap{"contacts": contactsSet})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -473,7 +470,7 @@ func flash(message string) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-func setupRoutes(mux *http.ServeMux, templates *template.Template) {
|
|
|
|
|
|
+func setupRoutes(mux *http.ServeMux) {
|
|
// OK
|
|
// OK
|
|
mux.Handle("/", RouteFront)
|
|
mux.Handle("/", RouteFront)
|
|
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
|
|
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
|
|
@@ -500,16 +497,7 @@ func setupRoutes(mux *http.ServeMux, templates *template.Template) {
|
|
|
|
|
|
func main() {
|
|
func main() {
|
|
mux := http.NewServeMux()
|
|
mux := http.NewServeMux()
|
|
- templates := template.Must(
|
|
|
|
- template.
|
|
|
|
- New("htmx-app").
|
|
|
|
- Funcs(sprig.FuncMap()). // Arithmetic, etc.
|
|
|
|
- Funcs(template.FuncMap{
|
|
|
|
- "get_flashed_messages": func() string { return "some message" },
|
|
|
|
- }).
|
|
|
|
- ParseGlob("./templates/*.gohtml"),
|
|
|
|
- )
|
|
|
|
- setupRoutes(mux, templates)
|
|
|
|
|
|
+ setupRoutes(mux)
|
|
(&Contact{}).LoadDB()
|
|
(&Contact{}).LoadDB()
|
|
if err := http.ListenAndServe(":8080", mux); err != nil {
|
|
if err := http.ListenAndServe(":8080", mux); err != nil {
|
|
if !errors.Is(err, http.ErrServerClosed) {
|
|
if !errors.Is(err, http.ErrServerClosed) {
|