18 lines
374 B
Go
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)
|
|
}
|
|
}
|