diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-09 20:26:39 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-05-09 20:26:39 -0700 |
commit | 9e6cfdf9668157ec7ff566c670ce293b18d2bc83 (patch) | |
tree | 52c00b694b5ea63705f7608aa02eaf7ba3ec51d4 /golang/restapi/configure_fatcat.go | |
parent | c28602eba84c8c5ecfd267187ff103bb5e9d2091 (diff) | |
download | fatcat-9e6cfdf9668157ec7ff566c670ce293b18d2bc83.tar.gz fatcat-9e6cfdf9668157ec7ff566c670ce293b18d2bc83.zip |
basic sentry; middleware; clacks-overhead
Diffstat (limited to 'golang/restapi/configure_fatcat.go')
-rw-r--r-- | golang/restapi/configure_fatcat.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/golang/restapi/configure_fatcat.go b/golang/restapi/configure_fatcat.go index 418400fc..7398ad26 100644 --- a/golang/restapi/configure_fatcat.go +++ b/golang/restapi/configure_fatcat.go @@ -10,6 +10,10 @@ import ( runtime "github.com/go-openapi/runtime" middleware "github.com/go-openapi/runtime/middleware" graceful "github.com/tylerb/graceful" + "github.com/carbocation/interpose" + "github.com/carbocation/interpose/adaptors" + //"github.com/getsentry/raven-go" + "github.com/meatballhat/negroni-logrus" "git.archive.org/bnewbold/fatcat/golang/restapi/operations" ) @@ -67,5 +71,22 @@ func setupMiddlewares(handler http.Handler) http.Handler { // The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. // So this is a good place to plug in a panic handling middleware, logging and metrics func setupGlobalMiddleware(handler http.Handler) http.Handler { - return handler + + middle := interpose.New() + + // sentry and upstream + //middle.UseHandler(sentry.Recovery(raven.DefaultClient, false)) + + // logging + negroniMiddleware := negronilogrus.NewMiddleware() + middle.Use(adaptors.FromNegroni(negroniMiddleware)) + + // add clacks + middle.UseHandler(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + rw.Header().Set("X-Clacks-Overhead:", "GNU Aaron Swartz, John Perry Barlow") + })) + + middle.UseHandler(handler) + + return middle } |