package handler

import "net/http"

type Handler func(http.ResponseWriter, *http.Request) error

func (fn Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	if err := fn(w, r); err != nil {
		w.Header().Set("HX-Retarget", "#layout_content")
		w.Header().Set("HX-Reswap", "innerHTML")
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
