+13
appview/middleware/middleware.go
+13
appview/middleware/middleware.go
···
43
44
type middlewareFunc func(http.Handler) http.Handler
45
46
+
func (mw *Middleware) TryRefreshSession() middlewareFunc {
47
+
return func(next http.Handler) http.Handler {
48
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
49
+
_, auth, err := mw.oauth.GetSession(r)
50
+
if err != nil {
51
+
log.Println("could not refresh session", "err", err, "auth", auth)
52
+
}
53
+
54
+
next.ServeHTTP(w, r)
55
+
})
56
+
}
57
+
}
58
+
59
func AuthMiddleware(a *oauth.OAuth) middlewareFunc {
60
return func(next http.Handler) http.Handler {
61
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {