gocron/routers/routers.go

30 lines
672 B
Go
Raw Normal View History

2017-03-24 05:06:53 +00:00
package routers
2017-03-24 09:55:44 +00:00
import (
"gopkg.in/macaron.v1"
2017-04-01 09:04:40 +00:00
"github.com/ouqiang/cron-scheduler/routers/install"
"github.com/go-macaron/binding"
2017-03-24 09:55:44 +00:00
)
2017-03-24 05:06:53 +00:00
// 路由注册
func Register(m *macaron.Macaron) {
// 所有GET方法自动注册HEAD方法
m.SetAutoHead(true)
2017-04-01 09:04:40 +00:00
// 404错误
m.NotFound(func(ctx *macaron.Context) {
ctx.HTML(404, "error/404")
})
// 50x错误
m.InternalServerError(func(ctx *macaron.Context) {
ctx.HTML(500, "error/500")
})
2017-03-24 05:06:53 +00:00
// 首页
2017-04-01 09:04:40 +00:00
m.Get("/", func(ctx *macaron.Context) (string) {
2017-03-24 05:06:53 +00:00
return "go home"
})
2017-04-01 09:04:40 +00:00
// 系统安装
m.Group("/install", func() {
m.Get("", install.Show)
m.Post("", binding.Bind(install.InstallForm{}), install.Install)
})
2017-03-24 05:06:53 +00:00
}