aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFuXiaoHei <fuxiaohei@hexiaz.com>2014-03-21 21:35:48 +0800
committerFuXiaoHei <fuxiaohei@hexiaz.com>2014-03-21 21:35:48 +0800
commit6bc311c552f2b06ec45e2193aff5d7c7f61c9168 (patch)
tree57cd1b1c59d81af9f2f28fc3ef75352587de025e /modules
parent14ddb8b1fa9ccdd877f808112e38d2f0146fe3c2 (diff)
parent770c78a177c64ba2014f4152da95f0899495772a (diff)
Merge branch 'master' of https://github.com/gogits/gogs
Diffstat (limited to 'modules')
-rw-r--r--modules/base/conf.go16
-rw-r--r--modules/middleware/context.go5
2 files changed, 21 insertions, 0 deletions
diff --git a/modules/base/conf.go b/modules/base/conf.go
index bf054ec3..3962972c 100644
--- a/modules/base/conf.go
+++ b/modules/base/conf.go
@@ -15,6 +15,8 @@ import (
"github.com/Unknwon/com"
"github.com/Unknwon/goconfig"
+ "github.com/gogits/cache"
+
"github.com/gogits/gogs/modules/log"
)
@@ -37,6 +39,10 @@ var (
Cfg *goconfig.ConfigFile
MailService *Mailer
+
+ Cache cache.Cache
+ CacheAdapter string
+ CacheConfig string
)
var Service struct {
@@ -182,6 +188,16 @@ func NewConfigContext() {
SecretKey = Cfg.MustValue("security", "SECRET_KEY")
RunUser = Cfg.MustValue("", "RUN_USER")
+ CacheAdapter = Cfg.MustValue("cache", "ADAPTER")
+ CacheConfig = Cfg.MustValue("cache", "CONFIG")
+
+ Cache, err = cache.NewCache(CacheAdapter, CacheConfig)
+ if err != nil {
+ fmt.Printf("Init cache system failed, adapter: %s, config: %s, %v\n",
+ CacheAdapter, CacheConfig, err)
+ os.Exit(2)
+ }
+
// Determine and create root git reposiroty path.
RepoRootPath = Cfg.MustValue("repository", "ROOT")
if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil {
diff --git a/modules/middleware/context.go b/modules/middleware/context.go
index cb3cbabc..a25a3dbb 100644
--- a/modules/middleware/context.go
+++ b/modules/middleware/context.go
@@ -12,8 +12,11 @@ import (
"github.com/codegangsta/martini"
"github.com/martini-contrib/sessions"
+ "github.com/gogits/cache"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
+ "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
)
@@ -25,6 +28,7 @@ type Context struct {
Req *http.Request
Res http.ResponseWriter
Session sessions.Session
+ Cache cache.Cache
User *models.User
IsSigned bool
@@ -97,6 +101,7 @@ func InitContext() martini.Handler {
Req: r,
Res: res,
Session: session,
+ Cache: base.Cache,
Render: rd,
}