Esempio n. 1
0
func main() {
	models.Init()
	jobs.InitJobs()

	// 设置默认404页面
	beego.Errorhandler("404", func(rw http.ResponseWriter, r *http.Request) {
		t, _ := template.New("404.html").ParseFiles(beego.ViewsPath + "/error/404.html")
		data := make(map[string]interface{})
		data["content"] = "page not found"
		t.Execute(rw, data)
	})

	// 生产环境不输出debug日志
	if beego.AppConfig.String("runmode") == "prod" {
		beego.SetLevel(beego.LevelInformational)
	}
	beego.AppConfig.Set("version", VERSION)

	// 路由设置
	beego.Router("/", &controllers.MainController{}, "*:Index")
	beego.Router("/login", &controllers.MainController{}, "*:Login")
	beego.Router("/logout", &controllers.MainController{}, "*:Logout")
	beego.Router("/profile", &controllers.MainController{}, "*:Profile")
	beego.Router("/gettime", &controllers.MainController{}, "*:GetTime")
	beego.Router("/help", &controllers.HelpController{}, "*:Index")
	beego.AutoRouter(&controllers.TaskController{})
	beego.AutoRouter(&controllers.GroupController{})

	beego.SessionOn = true
	beego.Run()
}
Esempio n. 2
0
func Init() {

	//APP段接口
	beego.AutoRouter(&api.UserController{})
	beego.AutoRouter(&api.ArticleController{})

	//后台
	beego.Router("/admin", &admin.IndexController{}, "*:Index")
	beego.Router("/admin/login", &admin.AccountController{}, "*:Login")
	beego.Router("/admin/logout", &admin.AccountController{}, "*:Logout")
	beego.Router("/admin/account/profile", &admin.AccountController{}, "*:Profile")

	//用户管理
	beego.Router("/admin/user/list", &admin.UserController{}, "*:List")
	beego.Router("/admin/user/add", &admin.UserController{}, "*:Add")
	beego.Router("/admin/user/edit", &admin.UserController{}, "*:Edit")
	beego.Router("/admin/user/delete", &admin.UserController{}, "*:Delete")

	//内容管理
	beego.Router("/admin/article/add", &admin.ArticleController{}, "*:Add")
	beego.Router("/admin/article/upload", &admin.ArticleController{}, "*:Upload")
	beego.Router("/admin/article/save", &admin.ArticleController{}, "post:Save")
	beego.Router("/admin/article/delete", &admin.ArticleController{}, "*:Delete")
	beego.Router("/admin/article/batch", &admin.ArticleController{}, "*:Batch")
	beego.Router("/admin/article/list", &admin.ArticleController{}, "*:List")
	beego.Router("/admin/article/trash", &admin.ArticleController{}, "*:Trash")
	beego.Router("/admin/article/edit", &admin.ArticleController{}, "*:Edit")
	beego.Router("/admin/article/destroy", &admin.ArticleController{}, "*:Destroy")
	beego.Router("/admin/tag/list", &admin.TagController{}, "*:List")
	beego.Router("/admin/tag/delete", &admin.TagController{}, "*:Delete")
	beego.Router("/admin/tag/add", &admin.TagController{}, "*:Add")
}
Esempio n. 3
0
func main() {
	orm.Debug = true
	orm.RunSyncdb("default", false, true)

	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/reply", &controllers.ReplyController{})
	beego.AutoRouter(&controllers.ReplyController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.AutoRouter(&controllers.TopicController{})

	os.Mkdir("attachment", os.ModePerm)
	beego.SetStaticPath("/attachment", "attachment")

	err := i18n.SetMessage("en-US", "conf/locale_en-US.ini")
	if err != nil {
		beego.Error(err)
	}
	err = i18n.SetMessage("zh-CN", "conf/locale_zh-CN.ini")
	if err != nil {
		beego.Error(err)
	}
	err = i18n.SetMessage("zh-HK", "conf/locale_zh-HK.ini")
	if err != nil {
		beego.Error(err)
	}

	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}
Esempio n. 4
0
func init() {
	// 注册数据库
	models.RegisterDB()

	/*
	  注册 beego 固定路由
	*/
	/*
	  如下所示的路由就是我们最常用的路由方式,一个固定的路由,一个控制器,然后根据用户请求方法不同请求控制器中对应的方法,典型的 RESTful 方式。
	*/
	/*
	  除了前缀两个/:controller/:method的匹配之外,剩下的 url beego会帮你自动化解析为参数,保存在 this.Ctx.Input.Params 当中:
	  object/blog/2013/09/12  调用 ObjectController 中的 Blog 方法,参数如下:map[0:2013 1:09 2:12]
	*/
	/*
		现在已经可以通过自动识别出来下面类似的所有url,都会把请求分发到 controller 的 simple 方法:

		/controller/simple
		/controller/simple.html
		/controller/simple.json
		/controller/simple.rss

		可以通过 this.Ctx.Input.Param(":ext") 获取后缀名。
	*/

	beego.Router("/", &controllers.HomeController{})
	beego.Router("/home", &controllers.HomeController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.Router("/user", &controllers.UserController{})
	beego.Router("/reply", &controllers.ReplyController{})
	beego.Router("/login", &controllers.LoginController{})

	beego.Router("/load", &controllers.HomeController{}, "get:Load")
	beego.Router("/home/load", &controllers.HomeController{}, "get:Load")
	beego.Router("/category/load", &controllers.CategoryController{}, "get:Load")

	beego.Router("/category/delete", &controllers.CategoryController{}, "get:Delete")
	beego.Router("/reply/add", &controllers.ReplyController{}, "post:Add")
	beego.Router("/reply/delete", &controllers.ReplyController{}, "get:Delete")
	beego.Router("/attachment/:all", &controllers.AttachController{})

	/*
		智能路由
	*/
	/*
		有了这个AutoRouter,便不需要像以前那样逐一注册了,访问/user/add 调用UserController的Add方法,访问/page/about调用PageController的About方法。
	*/

	beego.AutoRouter(&controllers.UserController{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.Router("/topic/load", &controllers.TopicController{}, "get:Load")
	beego.Router("/user/load", &controllers.UserController{}, "get:Load")
	beego.Router("/topic/loadModify", &controllers.TopicController{}, "get:LoadModify")
	beego.Router("/topic/loadView", &controllers.TopicController{}, "get:LoadView")
	beego.Router("/user/loadModify", &controllers.UserController{}, "get:LoadModify")
	beego.Router("/user/loadView", &controllers.UserController{}, "get:LoadView")

}
Esempio n. 5
0
File: router.go Progetto: xieao/blog
func init() {
	beego.Router("/index", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})

	beego.AutoRouter(&controllers.MainController{})
	beego.AutoRouter(&controllers.ConfigController{})
	beego.StaticDir["/static"] = "static"
}
Esempio n. 6
0
func init() {
	//默认路由
	beego.Router("/", &controllers.MainController{})
	//用户操作
	//beego.Router("/Login", &controllers.UserController{}, "*:Login")
	beego.AutoRouter(&controllers.UserController{})
	beego.AutoRouter(&controllers.ProductController{})
}
Esempio n. 7
0
func init() {
	beego.InsertFilter("/main", beego.BeforeRouter, FilterUser)
	//beego.Router("/", &controllers.MainController{})
	beego.Router("/", &controllers.LoginController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.AutoRouter(&controllers.LoginController{})
	beego.Router("/main", &controllers.MainController{})
	beego.AutoRouter(&controllers.MainController{})
}
Esempio n. 8
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.AutoRouter(&controllers.ReplyController{})
	beego.AutoRouter(&controllers.CategoryController{})
}
Esempio n. 9
0
func init() {
	beego.Router("/", &controllers.IndexController{}, "*:Index")
	//beego.Router("/user", &controllers.UserController{})
	//beego.Router("/user/index", &controllers.UserController{}, "*:Index")
	beego.AutoRouter(&controllers.UserController{})
	beego.AutoRouter(&controllers.LoginController{})
	beego.AutoRouter(&controllers.IndexController{})
	beego.AutoRouter(&controllers.AccessController{})
	//beego.Router("/user/Get", &controllers.UserController{})
}
Esempio n. 10
0
func main() {
	beego.Router("/", &controllers.MainController{}, "*:Index")
	beego.AutoRouter(&controllers.IndexController{})
	beego.AutoRouter(&controllers.MainController{})
	beego.AutoRouter(&controllers.CategoryController{})
	beego.AutoRouter(&controllers.MenuController{})
	beego.AutoRouter(&controllers.UserController{})
	beego.AddFuncMap("hex", hex)
	beego.Run()
}
Esempio n. 11
0
func init() {
	beego.Router("/", &controllers.HomeController{})

	beego.Router("/captcha", &controllers.UserController{}, "get:NewCaptcha") //验证码

	beego.Router("/login", &controllers.UserController{}, "get:Login") //用户登录页

	beego.Router("/login", &controllers.UserController{}, "post:LoginAction") //用户登录Action

	beego.Router("/logout", &controllers.UserController{}, "get:Logout") //用户退出

	beego.Router("/register", &controllers.UserController{}, "get:Register") //用户注册页面

	beego.Router("/register", &controllers.UserController{}, "post:RegisterAction") //用户注册Action

	beego.Router("/getpwd", &controllers.UserController{}, "get:GetPwd") //密码找回页

	beego.Router("/getpwd", &controllers.UserController{}, "post:GetPwdAction") //密码找回Action

	beego.Router("/modifypwd", &controllers.UserController{}, "get:ModifyPWD") //密码找回修改密码页

	beego.Router("/modifypwd", &controllers.UserController{}, "post:ModifyPWDAction") //密码找回修改密码Action

	beego.Router("/user/delete/:id:int", &controllers.UserController{}, "get:DeleteUser") //删除用户

	beego.Router("/user/view/:username:string", &controllers.UserController{}, "get:GetUserInfo") //获取用户详情

	beego.Router("/topic", &controllers.TopicController{})

	beego.Router("/topic/add", &controllers.TopicController{}, "post:AddTopic") //发表文章

	beego.Router("/topic/view/:id:int", &controllers.TopicController{}, "get:ViewTopic") //查看文章

	beego.Router("/topic/view/:category:string", &controllers.TopicController{}, "get:ViewTopicByCategoryName") //根据文章查看文章列表

	beego.Router("/topic/delete/:id:int", &controllers.TopicController{}, "get:DeleteTopic") //删除文章

	beego.Router("/topic/modify/:id:int", &controllers.TopicController{}, "get:ModifyTopic") //修改文章页

	beego.Router("/topic/modify/:id:int", &controllers.TopicController{}, "post:ModifyTopicAction") //修改文章Action

	beego.AutoRouter(&controllers.TopicController{})

	beego.Router("/category", &controllers.CategoryController{}, "get:GetAllCategory") //获取所有的分类

	beego.Router("/category/add", &controllers.CategoryController{}, "post:AddCategory") //添加文章分类

	beego.Router("/category/modify", &controllers.CategoryController{}, "post:ModifyCategory") //修改文章分类

	beego.Router("/category/delete/:id:int", &controllers.CategoryController{}, "get:DeleteCategory") //删除文章分类

	beego.AutoRouter(&controllers.CategoryController{})

}
Esempio n. 12
0
func init() {
	beego.Router("/", &controllers.HomeController{})
	beego.Router("/adminlogin", &controllers.AdminLoginController{})
	beego.Router("/adminhome", &controllers.AdminHomeController{})
	beego.Router("/admincategory", &controllers.AdminCategoryController{})
	beego.Router("/admintopic", &controllers.AdminTopicController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.AutoRouter(&controllers.AdminTopicController{})
}
Esempio n. 13
0
func init() {
	beego.AutoRouter(&controllers.TopicController{})
	//自动路由只能匹配到/<controller>/<method>...,仅有/<controller>,自动路由如法匹配到
	beego.Router("/topic", &controllers.TopicController{})
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.AutoRouter(&controllers.ReplyController{})
	beego.Router("/reply", &controllers.ReplyController{})
	//beego.Router("/reply/add", &controllers.ReplyController{}, "post:Add")
	//beego.Router("/reply/delete", &controllers.ReplyController{}, "post:Add")
}
Esempio n. 14
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/hello", &controllers.HelloController{})
	beego.Router("/admin", &admin.AdminController{})
	beego.Router("/admin/info", &admin.AdminController{}, "get:Info") //"*:Info"
	beego.AutoRouter(&controllers.AutoController{})
}
Esempio n. 15
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.AutoRouter(&controllers.PointController{})
	beego.Router("/point/SavePoints", &controllers.PointController{}, "post:SavePoints")
	beego.Router("/point/GetTypeList", &controllers.PointController{}, "get:GetTypeList")
	beego.Router("/point/GetWeekPointsJson/:id", &controllers.PointController{}, "get:GetWeekPointsJson")
}
Esempio n. 16
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/whois", &controllers.WhoisController{})
	beego.AutoRouter(&controllers.WhoisController{})
	beego.Router("/plan", &controllers.PlanController{})
	beego.Router("/srv", &controllers.SrvController{})
}
Esempio n. 17
0
func init() {
	beego.Router("/", &controllers.IndexController{}, "get,post:Get")
	beego.AutoRouter(&controllers.ClientController{})
	beego.AutoRouter(&controllers.LoginController{})
	beego.AutoRouter(&controllers.MessageController{})
	/*
		beego.Router("/", &controllers.IndexController{}, "get,post:Get")
		beego.Router("/client/get", &controllers.ClientController{}, "get:Get")
		beego.Router("/login/login", &controllers.LoginController{}, "post:Login")
		beego.Router("/login/logout", &controllers.LoginController{}, "get:Logout")
		beego.Router("/login/islogin", &controllers.LoginController{}, "get:Islogin")
		beego.Router("/message/post", &controllers.MessageController{}, "post:Post")
		beego.Router("/message/fetch", &controllers.MessageController{}, "get:Fetch")
		beego.Router("/message/get", &controllers.MessageController{}, "get:Get")
		beego.Router("/request/get", &controllers.RequestController{}, "get:Get")
	*/
}
Esempio n. 18
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/signup", &controllers.SignupController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.Router("/forgetpasswd", &controllers.ForgetPasswdController{})
}
Esempio n. 19
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/logout", &controllers.LogoutController{})
	beego.Router("/catagory", &controllers.CatagoryController{})
	beego.Router("/article", &controllers.ArticleController{})
	beego.AutoRouter(&controllers.ArticleController{})
	beego.Router("/about", &controllers.AboutController{})
}
Esempio n. 20
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/reply/add", &controllers.ReplyController{}, "post:Add")
	beego.Router("/reply/del", &controllers.ReplyController{}, "get:Del")
}
Esempio n. 21
0
func main() {
	orm.Debug = true
	beego.SessionOn = true

	//	var FilterUser = func(ctx *context.Context) {
	//		beego.Debug("ddd",ctx.Request.RequestURI)
	//		_, ok := ctx.Input.Session("uid").(int)
	//		if !ok && ctx.Request.RequestURI != "/login" {
	//			ctx.Redirect(302, "/login")
	//		}
	//	}
	//
	//	beego.InsertFilter("/d/*",beego.BeforeExec,FilterUser)
	beego.AutoRouter(&controllers.MainController{})
	beego.AutoRouter(&controllers.OptionController{})
	beego.AutoRouter(&controllers.RedisController{})
	beego.Run()

}
Esempio n. 22
0
func init() {
	beego.Router("/", &controllers.IndexController{})
	beego.Router("/qdns", &controllers.QdnsController{})
	beego.Router("/runcmd", &controllers.RunCmdController{})
	beego.Router("/cron", &controllers.CronController{})
	beego.Router("/agent", &controllers.AgentController{})
	beego.Router("/jobs", &controllers.JobsController{})
	beego.Router("/todo", &controllers.TodoController{})
	beego.Router("/doc", &controllers.DocController{})
	beego.AutoRouter(&controllers.TodoController{})
}
Esempio n. 23
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/about", &controllers.AboutController{})
	beego.Router("/admin/logout", &controllers.LogoutController{})
	beego.AutoRouter(&controllers.ArticleController{})

	beego.AutoPrefix("/admin", &admin.AticleController{})
	beego.AutoPrefix("/admin", &admin.TypeController{})
	beego.AutoPrefix("/admin", &admin.ConfigController{})
	beego.AutoPrefix("/admin", &admin.ConstructController{})
}
Esempio n. 24
0
func init() {
	beego.Router("/", &controllers.HomeController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.Router("/photograph", &controllers.PhotographController{})
	beego.Router("/signup", &controllers.Signupcontroller{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.Router("/user/profile", &controllers.UserController{}, `get:Profile`)
	beego.Router("/api/user/profile", &controllers.UserController{}, `get:API_Profile`)

}
Esempio n. 25
0
func init() {
	beego.Router("/", &controllers.IndexController{})   //根路由跳转
	beego.AutoRouter(&controllers.IndexController{})    //根
	beego.AutoRouter(&controllers.UserController{})     //用户设置目录跳转
	beego.AutoRouter(&controllers.QuestionController{}) //问答目录跳转
	beego.AutoRouter(&controllers.LoveController{})
	beego.AutoRouter(&controllers.AnswerController{})
	beego.AutoRouter(&controllers.SystemController{})
	beego.AutoRouter(&controllers.JobController{})

}
Esempio n. 26
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/category", &controllers.CategroyController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.Router("/comment", &controllers.CommentControllers{})
	beego.Router("/xzq", &controllers.XzqController{})
	beego.AutoRouter(&controllers.TopicController{})
	// 附件处理
	os.Mkdir("attachment", os.ModePerm)
	beego.Router("/attachment/:all", &controllers.AttachController{})

}
Esempio n. 27
0
func init() {
	// modole test
	beego.Router("/test", &controllers.TestController{})
	// home
	beego.Router("/", &controllers.MainController{})
	// login
	beego.Router("/login", &controllers.LoginController{})
	// logout
	beego.Router("/logout", &controllers.LogoutController{})
	//
	beego.Router("/category", &controllers.CategoryController{})
	//
	beego.Router("/topic", &controllers.TopicController{})
	//
	beego.Router("/comment", &controllers.CommentController{})
	//
	// beego.Router("/attachment/:all", &controllers.AttachmentController{})
	// 使用自动路由

	beego.AutoRouter(&controllers.TopicController{})
	beego.AutoRouter(&controllers.CommentController{})
}
Esempio n. 28
0
func Init() {
	// Index
	beego.Router("/", &controllers.Default{}, "GET:Index")

	// User
	beego.AutoRouter(&controllers.User{})

	// Space
	beego.Router("/space/:username", &controllers.User{}, "GET:Space")

	// Search
	beego.Router("/search", &controllers.Default{}, "GET:Search")
}
Esempio n. 29
0
File: router.go Progetto: lcbyz/Go
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.Router("/about", &controllers.AboutController{})
	langs := strings.Split(beego.AppConfig.String("types"), "|")

	for _, lang := range langs {
		if err := i18n.SetMessage(lang, "conf/"+"locale_"+lang+".ini"); err != nil {
			beego.Error(err.Error())
		}
	}
	beego.AddFuncMap("i18n", i18n.Tr)
}
Esempio n. 30
0
func main() {
	orm.Debug = true

	/* 自动建表 */
	orm.RunSyncdb("default", false, true)

	beego.Router("/", &controllers.HomeController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/topic", &controllers.TopicController{})
	beego.AutoRouter(&controllers.TopicController{})
	beego.Router("/category", &controllers.CategoryController{})

	beego.Run()
}