Пример #1
0
func main() {
	beego.DirectoryIndex = true
	beego.StaticDir["/beeapi"] = "beeapi"
	beego.Errorhandler("404", loadPageNotFound)
	beego.Errorhandler("show-database-error", loadDatabaseError)
	beego.Run()
}
Пример #2
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()
}
Пример #3
0
func init() {
	beego.Errorhandler("404", page_not_found)
	beego.Router("/", &controllers.MainController{})
	beego.Router("/packages.json", &controllers.PluginController{}, "get:Get")
	beego.Router("/plugins", &controllers.PluginController{}, "post:Post")
	beego.Router("/archive/:plugin([A-Za-z0-9]+)/:version(.*)", &controllers.DownloadController{})
}
Пример #4
0
func LoadRouters() {
	log.Info("加载路由信息")

	beego.Errorhandler("404", NotFound)
	beego.Errorhandler("500", ServerErr)

	// beego.SetStaticPath("/img", "blog/img")
	beego.AutoRouter(&controllers.AdminController{})
	beego.Router("/admin", &controllers.AdminController{})
	beego.Router("/", &controllers.IndexController{})
	beego.Router("/blog/:id", &controllers.BlogController{})
	beego.Router("/tag", &controllers.TagController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/:year:int/:month:int", &controllers.ArchiveController{})
	beego.Router("/search", &controllers.SearchController{})

}
Пример #5
0
func main() {
	//	beego.AutoRender = false
	beego.ViewsPath = "tpl" //模板存储目录
	beego.SessionOn = true  //SESSION开启

	mime.AddExtensionType(".css", "text/css")              //CSS 输出页头Content-Type
	mime.AddExtensionType(".js", "application/javascript") //JS 输出页头Content-Type
	beego.SetStaticPath("/static", "static")               //注册静态文件目录
	beego.Errorhandler("404", page404)
	beego.Run()
}
Пример #6
0
func init() {
	beego.Errorhandler("404", controllers.Error404)
	beego.Errorhandler("403", controllers.Error403)
	beego.Errorhandler("500", controllers.Error500)
	beego.Errorhandler("Once", controllers.ErrorOnce)
	beego.Errorhandler("IPBan", controllers.ErrorIPBan)

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

	//登录
	authController := new(controllers.AuthController)
	beego.Router("/login", authController, "get:Login;post:DoLogin")
	beego.Router("/login/:returnurl(.+)", authController, "get:Login")
	beego.Router("/forget-password", authController, "get:ForgetPassword;post:ForgetPassword")
	beego.Router("/reset-password/:code([0-9a-zA-Z]+)", authController, "get:ResetPassword;post:ResetPassword")
	beego.Router("/logout", authController, "get:Logout")
	beego.Router("/register", authController, "get:Register;post:DoRegister")
	beego.Router("/register/validate-username", authController, "get:ValidateUsername")
	beego.Router("/register/validate-email", authController, "get:ValidateEmail")
	beego.Router("/register/validate-captcha", authController, "get:ValidateCaptcha")
	beego.Router("/activate/:code([0-9a-zA-Z]+)", authController, "get:Activate")
	//社交帐号登录
	beego.InsertFilter("/login/*:/access", beego.BeforeRouter, controllers.OAuthAccess)
	beego.InsertFilter("/login/*:", beego.BeforeRouter, controllers.OAuthRedirect)
	socialAuthController := new(controllers.SocialAuthController)
	beego.Router("/register/connect", socialAuthController, "get:Connect;post:Connect")

	userController := new(controllers.UserController)
	beego.Router("/user/:username(.+)/edit", userController, "get:Edit;post:Edit")
	beego.Router("/user/:username(.+)/resend-validation", userController, "get:ResendValidation")
	beego.Router("/user/:username(.+)", userController, "get:Profile")
	beego.Router("/user-followunfollow", userController, "post:FollowUnfollow")
	beego.Router("/users", userController, "get:ListById")
	beego.Router("/users/by-rep", userController, "get:ListByRep")
	beego.Router("/users/by-digests", userController, "get:ListByDigests")
	beego.Router("/users/by-topics", userController, "get:ListByTopics")
	beego.Router("/users/by-comments", userController, "get:ListByComments")
	beego.Router("/users/by-followers", userController, "get:ListByFollowers")
}
Пример #7
0
func main() {

	beego.Errorhandler("404", page_not_found)

	beego.Router("/", &controllers.DefaultController{})
	beego.Router("/admin/login/", &controllers.AdminLoginController{})
	beego.Router("/admin/logout/", &controllers.AdminLogoutController{})
	beego.Router("/admin/index/", &controllers.AdminIndexController{})

	beego.Router("/auth/callback/", &controllers.AuthCallController{})
	beego.Router("/auth/cancel/callback/", &controllers.AuthCancelCallController{})

	beego.Run()
}
Пример #8
0
func Error_init() {
	beego.Errorhandler("404", NotFound)
}
Пример #9
0
func main() {
	beego.Errorhandler("404", P404)
	beego.Run()
}
Пример #10
0
func main() {
	beego.Errorhandler("404", page404)
	beego.InsertFilter("*", beego.BeforeExec, (beego.FilterFunc)(filter))
	beego.Run()
}
Пример #11
0
Файл: main.go Проект: z2665/t12
//加入静态文件服务目录
func main() {
	beego.SetStaticPath("/static", "./static")
	beego.Errorhandler("404", controllers.Page_not_found)
	beego.Run()

}