30 lines
988 B
Go
30 lines
988 B
Go
package ezhandler
|
|
|
|
import "net/http"
|
|
|
|
func NewHelper(errH ErrorHandler) *Helper {
|
|
return &Helper{errH}
|
|
}
|
|
|
|
// ErrorHandler writes an appropriate response to the [http.ResponseWriter] for the provided [error].
|
|
// If the [error] is nil, it should be a no op.
|
|
type ErrorHandler func(http.ResponseWriter, *http.Request, error)
|
|
|
|
// Helper provides methods to make easier, more idiomatic [http.Handler]s.
|
|
type Helper struct{
|
|
errHandler ErrorHandler
|
|
}
|
|
|
|
// Handler returns an [http.Handler] for the provided [Handler].
|
|
// If hnd returns an error, an appropriate error response is written using the ErrorHandler.
|
|
func (help *Helper) Handler(hnd Handler) http.Handler {
|
|
// TODO implement this
|
|
panic("unimplemented")
|
|
}
|
|
|
|
// Handler returns an [http.Handler] for the provided [HandlerFunc].
|
|
// If hnd returns an error, an appropriate error response is written using the ErrorHandler.
|
|
func (help *Helper) HandlerFunc(hnd HandlerFunc) http.Handler {
|
|
// TODO implement this
|
|
panic("unimplemented")
|
|
}
|