package routes import ( "devops/entities" "net/http" "zestack.dev/slim" ) func authSession(c slim.Context, next slim.HandlerFunc) error { sess, err := store.Get(c.Request(), "session-key") if err != nil { return err } user, ok := sess.Values["user"].(*entities.User) if !ok { return c.Redirect(http.StatusMovedPermanently, "/login") } c.Set("user", user) return next(c) }