joist/internal/routing/handler.go
2025-09-06 23:53:58 -04:00

17 lines
389 B
Go

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