init
This commit is contained in:
31
internal/server/errors.go
Normal file
31
internal/server/errors.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (srv *server) serverError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
var (
|
||||
method = r.Method
|
||||
uri = r.URL.RequestURI()
|
||||
trace = "" //string(debug.Stack())
|
||||
)
|
||||
|
||||
srv.logger.Error(err.Error(), "method", method, "uri", uri, "trace", trace)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// Logs server errors silently (without generating http:50x)
|
||||
func (srv *server) serverErrorSilent(w http.ResponseWriter, r *http.Request, err error) {
|
||||
var (
|
||||
method = r.Method
|
||||
uri = r.URL.RequestURI()
|
||||
trace = "" //string(debug.Stack())
|
||||
)
|
||||
|
||||
srv.logger.Error(err.Error(), "method", method, "uri", uri, "trace", trace)
|
||||
}
|
||||
|
||||
func (srv *server) clientError(w http.ResponseWriter, status int) {
|
||||
http.Error(w, http.StatusText(status), status)
|
||||
}
|
||||
Reference in New Issue
Block a user