当前位置: 首页>>代码示例>>Golang>>正文


Golang beego.InsertFilter函数代码示例

本文整理汇总了Golang中github.com/astaxie/beego.InsertFilter函数的典型用法代码示例。如果您正苦于以下问题:Golang InsertFilter函数的具体用法?Golang InsertFilter怎么用?Golang InsertFilter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了InsertFilter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	beego.SessionOn = true
	beego.InsertFilter("/appadmin/*", beego.BeforeRouter, auth.Basic("youradminname", "YourAdminPassword"))
	beego.InsertFilter("/hosts", beego.BeforeRouter, controllers.FilterLogin)
	beego.InsertFilter("/hosts/*", beego.BeforeRouter, controllers.FilterLogin)
	beego.Run()
}
开发者ID:robfrut135,项目名称:DockerWebConsole,代码行数:7,代码来源:main.go

示例2: Init

func Init() {
	beego.InsertFilter("*", beego.BeforeRouter, filterPostMethods)

	beego.InsertFilter("/steps/*", beego.BeforeExec, filterUser)
	beego.InsertFilter("/sites/*", beego.BeforeExec, filterUser)
	beego.InsertFilter("/sites/*", beego.BeforeExec, filterSiteOwner)
}
开发者ID:calavera,项目名称:openlandings,代码行数:7,代码来源:filters.go

示例3: NewWithFilter

// create a instance and create filter
func NewWithFilter(urlPrefix string, socialAuther SocialAuther) *SocialAuth {
	social := NewSocial(urlPrefix, socialAuther)

	beego.InsertFilter(social.URLPrefix+"*/access", beego.BeforeRouter, social.handleAccess)
	beego.InsertFilter(social.URLPrefix+"*", beego.BeforeRouter, social.handleRedirect)

	return social
}
开发者ID:naokij,项目名称:social-auth,代码行数:9,代码来源:social.go

示例4: main

func main() {
	beego.InsertFilter("/gui/*", beego.BeforeRouter, identity.FilterUser)
	beego.InsertFilter("/api/v1/*", beego.BeforeRouter, restapiidentity.FilterToken)
	beego.InsertFilter("/guirestapi/v1/*", beego.BeforeRouter, identity.FilterUser)

	beego.AppConfigPath = "/etc/cloudone_gui/app.conf"

	beego.Run()
}
开发者ID:cloudawan,项目名称:cloudone_gui,代码行数:9,代码来源:main.go

示例5: init

func init() {
	beego.Router("/", &controllers.IndexController{})
	beego.Router("/channels", &controllers.ChatController{}, "get:Index")
	beego.Router("/channels/new", &controllers.ChatController{}, "get,post:New")
	beego.Router("/channels/:id:int", &controllers.ChatController{}, "get:View")
	beego.Router("/users/login", &controllers.UserController{}, "get,post:Login")
	beego.Router("/users/logout", &controllers.UserController{}, "get,post:Logout")
	beego.Router("/users/register", &controllers.UserController{}, "get,post:Register")

	beego.InsertFilter("/*", beego.BeforeRouter, FilterUser)
	beego.InsertFilter("/channels/*", beego.BeforeRouter, FilterAuth)
}
开发者ID:nathan-osman,项目名称:pratl,代码行数:12,代码来源:router.go

示例6: main

func main() {
	beego.InsertFilter("*", beego.BeforeRouter, func(ctx *context.Context) {
		startTime := time.Now()
		ctx.Input.SetData("stats_timer", startTime)
	})
	beego.InsertFilter("*", beego.FinishRouter, func(ctx *context.Context) {
		Stats.EndWithStatus(ctx.Input.GetData("stats_timer").(time.Time), ctx.Output.Status)
	})

	beego.Router("/stats", &StatsController{})

	beego.Run()
}
开发者ID:ch3lo,项目名称:inspector,代码行数:13,代码来源:server.go

示例7: SocialAuthInit

func SocialAuthInit() {
	var clientId, secret string
	var err error
	appURL := beego.AppConfig.String("social_auth_url")
	if len(appURL) > 0 {
		social.DefaultAppUrl = appURL
	}

	clientId = beego.AppConfig.String("github_client_id")
	secret = beego.AppConfig.String("github_client_secret")
	err = social.RegisterProvider(apps.NewGithub(clientId, secret))
	if err != nil {
		beego.Error(err)
	}

	clientId = beego.AppConfig.String("google_client_id")
	secret = beego.AppConfig.String("google_client_secret")
	err = social.RegisterProvider(apps.NewGoogle(clientId, secret))
	if err != nil {
		beego.Error(err)
	}

	clientId = beego.AppConfig.String("weibo_client_id")
	secret = beego.AppConfig.String("weibo_client_secret")
	err = social.RegisterProvider(apps.NewWeibo(clientId, secret))
	if err != nil {
		beego.Error(err)
	}

	clientId = beego.AppConfig.String("qq_client_id")
	secret = beego.AppConfig.String("qq_client_secret")
	err = social.RegisterProvider(apps.NewQQ(clientId, secret))
	if err != nil {
		beego.Error(err)
	}

	clientId = beego.AppConfig.String("renren_client_id")
	secret = beego.AppConfig.String("renren_client_secret")
	err = social.RegisterProvider(apps.NewRenren(clientId, secret))
	if err != nil {
		beego.Error(err)
	}

	socialAuth.SocialAuth = social.NewSocial("/register/connect", new(socialAuth.SocialAuther))
	socialAuth.SocialAuth.ConnectSuccessURL = "/register/connect"
	beego.InsertFilter("/login", beego.BeforeRouter, filter.HandleAccess)
	beego.InsertFilter("/", beego.BeforeRouter, filter.HandleAccess)
	beego.InsertFilter("/login/*/access", beego.BeforeRouter, socialAuth.HandleAccess)
	beego.InsertFilter("/login/*", beego.BeforeRouter, socialAuth.HandleRedirect)
}
开发者ID:ming-hai,项目名称:account,代码行数:50,代码来源:setting.go

示例8: main

func main() {
	// Database alias.
	name := "default"

	// Drop table and re-create.
	force := true

	// Print log.
	verbose := true

	// Error.
	err := orm.RunSyncdb(name, force, verbose)
	if err != nil {
		fmt.Println(err)
	}
	o := orm.NewOrm()
	o.Using("default")
	seed(o)

	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowAllOrigins: true,
	}))

	beego.Run()
}
开发者ID:quannguyen89,项目名称:beego_api_demo,代码行数:25,代码来源:main.go

示例9: main

func main() {

	initialize()

	beego.Info(beego.AppName, APP_VER)

	beego.InsertFilter("/docs/images/:all", beego.BeforeRouter, routers.DocsStatic)

	if !routers.IsPro {
		beego.SetStaticPath("/static_source", "static_source")
		beego.DirectoryIndex = true
	}

	beego.SetStaticPath("/products/images", "products/images/")

	// Register routers.
	beego.Router("/", &routers.HomeRouter{})
	beego.Router("/community", &routers.CommunityRouter{})
	beego.Router("/quickstart", &routers.QuickStartRouter{})
	beego.Router("/video", &routers.VideoRouter{})
	beego.Router("/products", &routers.ProductsRouter{})
	beego.Router("/team", &routers.PageRouter{})
	beego.Router("/about", &routers.AboutRouter{})
	beego.Router("/donate", &routers.DonateRouter{})
	beego.Router("/docs/", &routers.DocsRouter{})
	beego.Router("/docs/:all", &routers.DocsRouter{})
	beego.Router("/blog", &routers.BlogRouter{})
	beego.Router("/blog/:all", &routers.BlogRouter{})

	// Register template functions.
	beego.AddFuncMap("i18n", i18n.Tr)

	beego.Run()
}
开发者ID:ningjh,项目名称:beeweb,代码行数:34,代码来源:beeweb.go

示例10: init

func init() {
	/*ns := beego.NewNamespace("/v1",
		beego.NSNamespace("/object",
			beego.NSInclude(
				&controllers.ObjectController{},
			),
		),
		beego.NSNamespace("/user",
			beego.NSInclude(
				&controllers.UserController{},
			),
		),

		beego.NSNamespace("/worker",
			//beego.NSNamespace("/querybagreq",
				beego.NSInclude(
					&controllers.WorkerController{},
				),
			//),
		),
	)
	beego.AddNamespace(ns)*/

	beego.Router("/v1/user", &controllers.UserController{})
	beego.Router("/v1/worker/querybagreq/:workerid/:token", &controllers.WorkerController{}, "get:Querybagreq")
	beego.Router("/v1/worker/getbagreq/:workerid/:token", &controllers.WorkerController{}, "get:Getbagreq")
	beego.Router("/v1/worker/getbagreqlist/:workerid/:token", &controllers.WorkerController{}, "get:GetbagreqList")
	beego.Router("/v1/worker/getworkerid", &controllers.WorkerController{}, "get:GetWorkerId")

	beego.Router("/v1/worker/postworkerinfo", &controllers.WorkerController{}, "*:PostWorkerInfo")
	beego.Router("/v1/worker/postworkerinfo1/:workerid/:token", &controllers.WorkerController{}, "post:PostWorkerInfo1")

	beego.InsertFilter("/v1/worker/getworkerid", beego.BeforeRouter, FilterUser)
}
开发者ID:colinwdk,项目名称:study_go,代码行数:34,代码来源:router.go

示例11: init

func init() {
	beego.Router("/", &controllers.RootController{})
	beego.Router("/login/?:dest", &controllers.LoginController{})
	beego.Router("/logout/?:dest", &controllers.LogoutController{})
	beego.Router("/signup/?:dest", &controllers.SignupController{})
	beego.Router("/live-editor/", &controllers.LiveEditorController{})
	beego.Router("/graphics-animation/", &controllers.GraphicsController{})
	beego.Router("/external/:file", &controllers.LiveEditorController{})

	beego.SetStaticPath("/build", "bootstrap/live-editor/build")

	var FilterUser = func(ctx *context.Context) {
		_, ok := ctx.Input.Session("uid").(int)
		if !ok {
			ctx.Redirect(302, "/login")
		}
	}

	beego.InsertFilter("/user/:id([0-9]+)", beego.BeforeRouter, FilterUser)

	beego.ErrorController(&controllers.ErrorController{})
	beego.SetLogger("file", `{"filename":"log/spielplatz.log"}`)

	loadLanguages()
}
开发者ID:lafisrap,项目名称:Computer-Spielplatz,代码行数:25,代码来源:router.go

示例12: RegisterControllers

func RegisterControllers() {
	//register maincontroller
	mc := new(MainController)
	beego.Router("/", mc, "get:Index")
	beego.Router("/index", mc, "get:Index")
	beego.Router("/extractor", mc, "get:Index") //react-router history route

	// "robot.txt"
	beego.Router("/robot.txt", &RobotRouter{})

	// Add Filters
	//todo:enable image filter later
	//  beego.InsertFilter("/img/*", beego.BeforeRouter, attachment.ImageFilter)

	beego.InsertFilter("/captcha/*", beego.BeforeRouter, setting.Captcha.Handler)
	//register user related controllers
	user.RegisterRoutes()
	userApi.RegisterRoutes()

	extractor := &magic.ExtractorController{}
	beego.Router("/api/extractor/parse", extractor, "get:Parse")

	//experiment
	exp := new(experiment.ExperimentController)
	beego.Router("/experiment", exp, "get:Index;post:Post")
}
开发者ID:thanzen,项目名称:identity,代码行数:26,代码来源:routeregister.go

示例13: main

func main() {
	core.Router_register()
	sso.Router_register()
	im.Router_register()
	schedule.Router_register()
	pay.Router_register()

	fmt.Println(beego.AppConfig.String("mysqluser"))
	fmt.Println(beego.AppConfig.String("mysqlpass"))
	fmt.Println(beego.AppConfig.String("mysqlurls"))
	fmt.Println(beego.AppConfig.String("mysqldb"))

	var FilterUser = func(ctx *context.Context) {
		if v := ctx.Input.Query("access_token"); v != "" {
			//data := "ok"
			fmt.Println(v)
			//ctx.Output.Json(data, false, true)
		} else {
			data := `{"error","err"}`
			ctx.Output.Json(data, false, true)
		}
	}

	beego.InsertFilter("*", beego.BeforeRouter, FilterUser)

	beego.Run()
}
开发者ID:ccpony86,项目名称:haiti,代码行数:27,代码来源:main.go

示例14: CheckAccessAndRegisterRes

func CheckAccessAndRegisterRes() {
	var Check = func(ctx *context.Context) {
		user_auth_type, _ := strconv.Atoi(beego.AppConfig.String("user_auth_type"))
		auth_gateway := beego.AppConfig.String("auth_gateway")
		var accessList map[string]bool
		if user_auth_type > 0 {
			params := strings.Split(strings.ToLower(ctx.Request.RequestURI), "/")
			if CheckAccess(params) {
				// 获取session value
				uinfo := ctx.Input.Session("userinfo")
				if uinfo == nil {
					ctx.Redirect(302, auth_gateway)
				}
				adminUser := beego.AppConfig.String("admin_user")
				//直接通过认证
				if uinfo.(User).Uname == adminUser {
					return
				}
				if user_auth_type == 1 {
					sessions := ctx.Input.Session("accesss")
					if sessions != nil {
						accessList = sessions.(map[string]bool)
					}
				} else if user_auth_type == 2 {
					accessList, _ = GetAccessList(uinfo.(User).Id)
				}
				ret := AccessDecision(params, accessList)
				if !ret {
					ctx.Output.Json(&map[string]interface{}{"status": false, "info": "权限不足"}, true, false)
				}
			}
		}
	}
	beego.InsertFilter("/", beego.BeforeRouter, Check)
}
开发者ID:fromiuan,项目名称:beego-bootstarpb-admin,代码行数:35,代码来源:Access.go

示例15: init

func init() {
	// config
	beego.BConfig.WebConfig.Session.SessionOn = true
	beego.BConfig.WebConfig.Session.SessionName = "SESSIONID"
	beego.BConfig.WebConfig.Session.SessionCookieLifeTime = ONE_DAYS
	beego.BConfig.WebConfig.Session.SessionGCMaxLifetime = 3600

	beego.Router("/", &controllers.HomeController{})
	beego.Router("/p/:page([0-9]+)", &controllers.HomeController{})
	beego.Router("/cat/:cat([a-zA-Z]+)", &controllers.CategoryController{})
	beego.Router("/cat/:cat([a-zA-Z]+)/p/:page([0-9]+)", &controllers.CategoryController{})
	beego.Router("/tag/:tag([a-zA-Z0-9\u4e00-\u9fa5]+)", &controllers.TagController{})
	beego.Router("/tag/:tag([a-zA-Z0-9\u4e00-\u9fa5]+)/p/:page([0-9]+)", &controllers.TagController{})
	beego.Router("/:year([0-9]{4})/:month([0-9]{2})/:day([0-9]{2})/:id([0-9]+).html", &controllers.TopicController{})
	beego.Router("/archives/:year([0-9]{4})/:month([0-9]{2})", &controllers.ArchivesController{})
	beego.Router("/message", &controllers.MessageController{})
	beego.Router("/about", &controllers.AboutController{})
	beego.Router("/search", &controllers.SearchController{})
	// admin
	beego.Router("/login", &background.AuthController{})
	beego.InsertFilter("/admin/*", beego.BeforeRouter, FilterUser)
	beego.Router("/admin/user", &background.UserController{})
	beego.Router("/admin/data", &background.DataController{})
	beego.Router("/admin/topics", &background.TopicsController{})
	beego.Router("/admin/category", &background.CategoryController{})
	beego.Router("/admin/message", &background.MessageController{})
	beego.Router("/admin/social", &background.SocialController{})
	beego.Router("/admin/blogroll", &background.BlogrollController{})
	beego.Router("/admin/ad", &background.ADController{})
	beego.Router("/admin/sysconfig", &background.SysconfigController{})
	beego.Router("/admin/databackup", &background.DataBackupRecover{})
	beego.Router("/admin/datarecover", &background.DataBackupRecover{})
	beego.Router("/admin/syslog", &background.SyslogController{})
	beego.Router("/admin/trash", &background.TrashController{})
	// proxy
	beego.Router("/proxy/:url(.*)", &proxy.ProxyController{})
	// rss
	beego.Get("/feed", feed.Feed)
	beego.Get("/sitemap", feed.SiteMap)
	beego.Get("/robots.txt", feed.Robots)
	// 404
	beego.ErrorHandler("404", HTTPNotFound)
	// redirect https
	beego.InsertFilter("*", beego.BeforeRouter, RedirectHttps)
	// plugin
	beego.Router("/plugin/useragent.html", &plugin.UserAgent{})
}
开发者ID:deepzz0,项目名称:goblog,代码行数:47,代码来源:router.go


注:本文中的github.com/astaxie/beego.InsertFilter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。