17 lines
389 B
Go
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)
|
|
}
|
|
}
|