split website/mux
1 file changed, 9 insertions(+), 2 deletions(-)
changed files
M internal/http/mux.go → internal/http/mux.go
@@ -6,7 +6,10 @@ "go.alanpearce.eu/x/log" ) -type WebHandler func(http.ResponseWriter, *http.Request) *Error +type HandleFunc func(http.ResponseWriter, *http.Request) *Error +type Handler interface { + ServeHTTP(http.ResponseWriter, *http.Request) *Error +} type ErrorHandler func(*Error, http.ResponseWriter, *http.Request) type ServeMux struct {@@ -24,7 +27,11 @@ }, } } -func (sm *ServeMux) HandleFunc(pattern string, handler WebHandler) { +func (sm *ServeMux) Handle(pattern string, handler Handler) { + sm.HandleFunc(pattern, handler.ServeHTTP) +} + +func (sm *ServeMux) HandleFunc(pattern string, handler HandleFunc) { sm.ServeMux.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) { defer func() { if fail := recover(); fail != nil {