joist/handler.go
2025-09-06 17:56:59 -04:00

18 lines
374 B
Go

package joist
import (
"fmt"
"net/http"
)
type (
HandlerFn func(w http.ResponseWriter, r *http.Request) error
MiddlewareFn func(HandlerFn) HandlerFn
)
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)
}
}