diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-06-11 10:10:18 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-06-11 10:10:18 +0700 |
| commit | 2017f3a809beeece6cc9cbceeba6bea032a0ecd6 (patch) | |
| tree | aaac02c81d32d1e4df779e49c39b1a50e8cc64ab /lib/http | |
| parent | 9ca9757dc36412466f0103cb069ec0b7f051f657 (diff) | |
| download | pakakeh.go-2017f3a809beeece6cc9cbceeba6bea032a0ecd6.tar.xz | |
http: log endpoint call only if its not instance of errors.E
Diffstat (limited to 'lib/http')
| -rw-r--r-- | lib/http/endpoint.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/http/endpoint.go b/lib/http/endpoint.go index 4b084233..a5391cb6 100644 --- a/lib/http/endpoint.go +++ b/lib/http/endpoint.go @@ -113,7 +113,7 @@ func (ep *Endpoint) call( for _, eval := range evaluators { e = eval(req, reqBody) if e != nil { - ep.error(res, e) + ep.error(res, req, e) return } } @@ -121,17 +121,14 @@ func (ep *Endpoint) call( if ep.Eval != nil { e = ep.Eval(req, reqBody) if e != nil { - ep.error(res, e) + ep.error(res, req, e) return } } rspb, e := ep.Call(res, req, reqBody) if e != nil { - log.Printf("endpoint.call: %d %s %s %s\n", - http.StatusInternalServerError, - req.Method, req.URL.Path, e) - ep.error(res, e) + ep.error(res, req, e) return } @@ -159,13 +156,17 @@ func (ep *Endpoint) call( } } -func (ep *Endpoint) error(res http.ResponseWriter, err error) { +func (ep *Endpoint) error(res http.ResponseWriter, req *http.Request, err error) { errInternal := &errors.E{} if stderrors.As(err, &errInternal) { if errInternal.Code <= 0 || errInternal.Code >= 512 { errInternal.Code = http.StatusInternalServerError } } else { + log.Printf("endpoint.call: %d %s %s %s\n", + http.StatusInternalServerError, + req.Method, req.URL.Path, err) + errInternal = errors.Internal(err) } |
