mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-06 20:48:47 +00:00
* Delete middleware package, move aws to new package * Refactor github_client into github package * Move terraform_client to its own package
26 lines
642 B
Go
26 lines
642 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/hootsuite/atlantis/logging"
|
|
"github.com/urfave/negroni"
|
|
)
|
|
|
|
func NewNon200Logger(logger *logging.SimpleLogger) *FailedRequestLogger {
|
|
return &FailedRequestLogger{logger}
|
|
}
|
|
|
|
// FailedRequestLogger logs the request when a response code >= 400 is sent
|
|
type FailedRequestLogger struct {
|
|
logger *logging.SimpleLogger
|
|
}
|
|
|
|
func (l *FailedRequestLogger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
|
next(rw, r)
|
|
res := rw.(negroni.ResponseWriter)
|
|
if res.Status() >= 400 {
|
|
l.logger.Info("%s %s - Response code %d", r.Method, r.URL.RequestURI(), res.Status())
|
|
}
|
|
}
|