Files
atlantis/middleware/middleware.go
Luke Kysow d425de95fa Refactoring
* set version in one place
* rename ExecutionContext to CommandContext
* delete unneeded PullRequestContext since it just duplicated what is in CommandContext
* split fields inside CommandContext into Repo, PullRequest, and User models
* clean up unused fields
* remove base_executor stuff which was trying to do inheritance in go and didn't get us anywhere
* clean up unused code and assets
* created a locking.Client that creates the Keys that are used on the front-end. This allows the backends to store the locks any way they like as long as they support the interface
2017-06-17 14:14:21 -07:00

25 lines
645 B
Go

package middleware
import (
"github.com/hootsuite/atlantis/logging"
"github.com/urfave/negroni"
"net/http"
)
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())
}
}