Browse Source

add m.NotFound handler

for-closed-social
FuXiaoHei 10 years ago
parent
commit
bdd32f152d
2 changed files with 10 additions and 0 deletions
  1. +7
    -0
      routers/dashboard.go
  2. +3
    -0
      web.go

+ 7
- 0
routers/dashboard.go View File

@ -20,5 +20,12 @@ func Home(ctx *middleware.Context) {
func Help(ctx *middleware.Context) {
ctx.Data["PageIsHelp"] = true
ctx.Data["Title"] = "Help"
ctx.HTML(200, "help")
}
func NotFound(ctx *middleware.Context) {
ctx.Data["PageIsNotFound"] = true
ctx.Data["Title"] = 404
ctx.Handle(404, "home.NotFound", nil)
}

+ 3
- 0
web.go View File

@ -163,6 +163,9 @@ func runWeb(*cli.Context) {
m.Get("/template/**", dev.TemplatePreview)
}
// not found handler
m.NotFound(routers.NotFound)
listenAddr := fmt.Sprintf("%s:%s",
base.Cfg.MustValue("server", "HTTP_ADDR"),
base.Cfg.MustValue("server", "HTTP_PORT", "3000"))

Loading…
Cancel
Save