From d6a5399da9853a3a7f00f1535001c0f90fcad704 Mon Sep 17 00:00:00 2001 From: ouqiang Date: Wed, 12 Apr 2017 14:10:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=9C=AA=E5=AE=89=E8=A3=85?= =?UTF-8?q?=EF=BC=8C=E9=87=8D=E5=AE=9A=E5=90=91=E5=88=B0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/web.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/web.go b/cmd/web.go index 9ced163..04091d4 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -15,6 +15,7 @@ import ( "syscall" "github.com/ouqiang/gocron/modules/logger" "github.com/go-macaron/toolbox" + "strings" ) // 1号进程id @@ -88,6 +89,16 @@ func registerMiddleware(m *macaron.Macaron) { m.Use(session.Sessioner()) m.Use(csrf.Csrfer()) m.Use(toolbox.Toolboxer(m)) + // 系统未安装,重定向到安装页面 + m.Use(func(ctx *macaron.Context) { + installUrl := "/install" + if strings.HasPrefix(ctx.Req.RequestURI, installUrl) { + return + } + if !app.Installed { + ctx.Redirect(installUrl) + } + }) } // 解析端口