]> source.dussan.org Git - gitea.git/commitdiff
Use toolbox
authorUnknwon <joe2010xtmf@163.com>
Wed, 6 Aug 2014 21:21:24 +0000 (17:21 -0400)
committerUnknwon <joe2010xtmf@163.com>
Wed, 6 Aug 2014 21:21:24 +0000 (17:21 -0400)
.gitignore
cmd/web.go
gogs.go
models/models.go
routers/dev/debug.go [deleted file]
routers/user/home.go
templates/.VERSION

index c24f364baa32ec87b9bd42dd3836cd2c36aa72e2..e8b5ee1f93f7409a7cd149bb491fc504cc4c5873 100644 (file)
@@ -33,6 +33,7 @@ _testmain.go
 *.exe
 *.exe~
 /gogs
+profile/
 __pycache__
 *.pem
 output*
index 995aeb04a9142cba1d751dcae43b9b70528a6d05..8d39ce64c8567071e0add77b654275c6d1fe17fb 100644 (file)
@@ -19,7 +19,9 @@ import (
        "github.com/macaron-contrib/csrf"
        "github.com/macaron-contrib/i18n"
        "github.com/macaron-contrib/session"
+       "github.com/macaron-contrib/toolbox"
 
+       "github.com/gogits/gogs/models"
        "github.com/gogits/gogs/modules/auth"
        "github.com/gogits/gogs/modules/auth/apiv1"
        "github.com/gogits/gogs/modules/avatar"
@@ -62,20 +64,20 @@ func newMacaron() *macaron.Macaron {
        m := macaron.New()
        m.Use(macaron.Logger())
        m.Use(macaron.Recovery())
-       if setting.EnableGzip {
-               m.Use(macaron.Gzip())
-       }
        m.Use(macaron.Static("public",
                macaron.StaticOptions{
                        SkipLogging: !setting.DisableRouterLog,
                },
        ))
+       if setting.EnableGzip {
+               m.Use(macaron.Gzip())
+       }
        m.Use(macaron.Renderer(macaron.RenderOptions{
                Directory:  path.Join(setting.StaticRootPath, "templates"),
                Funcs:      []template.FuncMap{base.TemplateFuncs},
                IndentJSON: macaron.Env != macaron.PROD,
        }))
-       m.Use(i18n.I18n(i18n.LocaleOptions{
+       m.Use(i18n.I18n(i18n.Options{
                Langs:    setting.Langs,
                Names:    setting.Names,
                Redirect: true,
@@ -95,6 +97,14 @@ func newMacaron() *macaron.Macaron {
                SetCookie: true,
        }))
        m.Use(middleware.Contexter())
+       m.Use(toolbox.Toolboxer(m, toolbox.Options{
+               HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
+                       &toolbox.HealthCheckFuncDesc{
+                               Desc: "Database connection",
+                               Func: models.Ping,
+                       },
+               },
+       }))
        return m
 }
 
@@ -208,7 +218,6 @@ func runWeb(*cli.Context) {
 
        if macaron.Env == macaron.DEV {
                m.Get("/template/*", dev.TemplatePreview)
-               dev.RegisterDebugRoutes(m)
        }
 
        reqTrueOwner := middleware.RequireTrueOwner()
diff --git a/gogs.go b/gogs.go
index c395276be7e0f9cec6851e6470b87543c84af9c0..b08dbd5a5f9a7ad7575b4358a2311a27a02263ff 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
        "github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.4.7.0805 Alpha"
+const APP_VER = "0.4.7.0806 Alpha"
 
 func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
index 31509ed349aa255702ff8be2fa865e971fc2a2df..af9529f40a38143eda374a781e429d34c181610f 100644 (file)
@@ -165,6 +165,10 @@ func GetStatistic() (stats Statistic) {
        return
 }
 
+func Ping() error {
+       return x.Ping()
+}
+
 // DumpDatabase dumps all data from database to file system.
 func DumpDatabase(filePath string) error {
        return x.DumpAllToFile(filePath)
diff --git a/routers/dev/debug.go b/routers/dev/debug.go
deleted file mode 100644 (file)
index 7d737d8..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2014 The Gogs Authors. All rights reserved.\r
-// Use of this source code is governed by a MIT-style\r
-// license that can be found in the LICENSE file.\r
-\r
-package dev\r
-\r
-import (\r
-       "net/http/pprof"\r
-\r
-       "github.com/Unknwon/macaron"\r
-)\r
-\r
-func RegisterDebugRoutes(r *macaron.Macaron) {\r
-       r.Any("/debug/pprof/cmdline", pprof.Cmdline)\r
-       r.Any("/debug/pprof/profile", pprof.Profile)\r
-       r.Any("/debug/pprof/symbol", pprof.Symbol)\r
-       r.Any("/debug/pprof/*", pprof.Index)\r
-}\r
index 706c16d91f9d8a04dbe0472611697ea84ab4ca76..177fa38be3f61a34348ad177c58aa533db570b3c 100644 (file)
@@ -119,12 +119,19 @@ func Profile(ctx *middleware.Context) {
        ctx.Data["Title"] = "Profile"
        ctx.Data["PageIsUserProfile"] = true
 
-       u, err := models.GetUserByName(ctx.Params(":username"))
+       uname := ctx.Params(":username")
+       // Special handle for FireFox requests favicon.ico.
+       if uname == "favicon.ico" {
+               ctx.Redirect("/img/favicon.png")
+               return
+       }
+
+       u, err := models.GetUserByName(uname)
        if err != nil {
                if err == models.ErrUserNotExist {
-                       ctx.Handle(404, "user.Profile(GetUserByName)", err)
+                       ctx.Handle(404, "GetUserByName", err)
                } else {
-                       ctx.Handle(500, "user.Profile(GetUserByName)", err)
+                       ctx.Handle(500, "GetUserByName", err)
                }
                return
        }
@@ -146,13 +153,13 @@ func Profile(ctx *middleware.Context) {
        case "activity":
                ctx.Data["Feeds"], err = models.GetFeeds(u.Id, 0, true)
                if err != nil {
-                       ctx.Handle(500, "user.Profile(GetFeeds)", err)
+                       ctx.Handle(500, "GetFeeds", err)
                        return
                }
        default:
                ctx.Data["Repos"], err = models.GetRepositories(u.Id, ctx.IsSigned && ctx.User.Id == u.Id)
                if err != nil {
-                       ctx.Handle(500, "user.Profile(GetRepositories)", err)
+                       ctx.Handle(500, "GetRepositories", err)
                        return
                }
        }
index 833e3a16dd1fd58a0c9892f416c30d6354e18f67..04e73b67f7db3f586290300650896c1ff5c7f232 100644 (file)
@@ -1 +1 @@
-0.4.7.0805 Alpha
\ No newline at end of file
+0.4.7.0806 Alpha
\ No newline at end of file