Instead of having http.Error() and return scattered throughout the codebase, have a single location for handling errors. This may be done by providing an internal handler and handlerFunc type that match the http.Handler but return an error. This, along with an error type that indicates the http status code to use would greatly simplify the handlers and enable more robust and unified error response and logging for the server.
Instead of having
http.Error()
andreturn
scattered throughout the codebase, have a single location for handling errors. This may be done by providing an internalhandler
andhandlerFunc
type that match thehttp.Handler
but return an error. This, along with an error type that indicates the http status code to use would greatly simplify the handlers and enable more robust and unified error response and logging for the server.