package joist import ( "fmt" "net/http" ) type HandlerFn func(w http.ResponseWriter, r *http.Request) error func (h HandlerFn) ServeHTTP(w http.ResponseWriter, r *http.Request) { if err := h(w, r); err != nil { http.Error(w, fmt.Sprintf(`An internal error has occurred: %s`, err), http.StatusInternalServerError) return } } func (h HandlerFn) ToHandlerFunc() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { h.ServeHTTP(w, r) } }