Exemple #1
0
// Get returns the namespace for public education
func Get() *beego.Namespace {
	ns := beego.NewNamespace("education",
		beego.NSRouter("", &education.Home{}, "*:Display"),
		beego.NSNamespace("subjects/:subject",
			beego.NSRouter("", &subject.Subject{}, "GET:Display"),
		),
	)
	return ns
}
Exemple #2
0
// Get returns the namespace for log
func Get() func(*beego.Namespace) {
	ns := beego.NSNamespace("/log",
		beego.NSRouter("", &log.Home{}, "*:Display"),
		getHarvest(),
		beego.NSRouter("/advance-options", &log.Home{}, "*:DisplayAdvanceOptions"),
		beego.NSRouter("/delete", &log.Home{}, "POST:Delete"),
	)
	return ns
}
Exemple #3
0
// Get returns the routers for the education
func Get() func(*beego.Namespace) {
	subject := getSubject()
	ns := beego.NSNamespace("/education",
		beego.NSRouter("/analyse", &education.Home{}, "GET:Analyse"),
		beego.NSRouter("/analyser/:analyser/delete", &education.Home{}, "POST:DeleteAnalyser"),
		beego.NSRouter("", &education.Home{}, "*:Display"),
		subject,
	)
	return ns
}
Exemple #4
0
// Get returns the Namespace for data
func Get() func(*beego.Namespace) {
	ns := beego.NSNamespace("/data/",
		beego.NSNamespace("/table",
			beego.NSRouter("", &data.Table{}, "GET:ShowList"),
			beego.NSRouter("generate/:name", &data.Table{}, "*:Generate"),
			beego.NSRouter("download/:name", &data.Table{}, "*:Download"),
		),
	)
	return ns
}
Exemple #5
0
// Get returns the namespace for api
func getSearch() func(*beego.Namespace) {
	ns := beego.NSNamespace("/search",
		beego.NSNamespace("/anything/:query",
			beego.NSRouter("", &api.Search{}, "*:SearchAnything"),
		),
		beego.NSNamespace("/save/:query",
			beego.NSRouter("", &api.Search{}, "POST:JustSaveAccountQuery"),
		),
	)
	return ns
}
Exemple #6
0
// Get returns the Namespace for the repositories
func Get() *beego.Namespace {
	ns := beego.NewNamespace("/repositories/",
		beego.NSNamespace(":repository",
			beego.NSRouter("", &repository.Repository{}, "GET:Display"),
			beego.NSNamespace("/resources",
				beego.NSRouter("/:resource", &repository.Repository{}, "GET:DisplayResource"),
			),
		),
	)
	return ns
}
Exemple #7
0
// Get returns the Namespace for the accounts within administration area
func Get() func(*beego.Namespace) {
	ns := beego.NSNamespace("/accounts",
		beego.NSRouter("", &accountsController.Home{}, "*:Display"),
		beego.NSNamespace("/:account",
			beego.NSNamespace("/modify",
				beego.NSRouter("", &accountController.Account{}, "GET:ShowModifyForm"),
				beego.NSRouter("", &accountController.Account{}, "POST:Modify"),
			),
			beego.NSRouter("/delete", &accountController.Account{}, "POST:Delete"),
		),
	)
	return ns
}
Exemple #8
0
func ConfigRoutes() {
	//owl-protal-routes
	portal := beego.NewNamespace("/api/v1/portal",
		beego.NSGet("/notallowed", func(ctx *context.Context) {
			ctx.Output.Body([]byte("notAllowed"))
		}),
		beego.NSRouter("/eventcases/get", &PortalController{}, "get:EventCasesGet;post:EventCasesGet"),
		beego.NSRouter("/events/get", &PortalController{}, "get:EventGet;post:EventGet"),
		beego.NSRouter("/eventcases/close", &PortalController{}, "get:ColseCase;post:ColseCase;put:ColseCase"),
		beego.NSRouter("/tpl/count", &PortalController{}, "get:CountNumOfTlp;post:CountNumOfTlp"),
	)
	beego.AddNamespace(portal)
}
Exemple #9
0
// Get returns the Namespace for data
func Get() func(*beego.Namespace) {
	ns := beego.NSNamespace("/tools",
		beego.NSNamespace("/digester",
			beego.NSRouter("", &tools.Digester{}, "GET:Display"),
			beego.NSRouter("", &tools.Digester{}, "POST:Work"),
		),
		beego.NSNamespace("/web-digester",
			beego.NSRouter("", &tools.WebDigester{}, "GET:Display"),
			beego.NSRouter("", &tools.WebDigester{}, "POST:Work"),
		),
	)
	return ns
}
Exemple #10
0
func getHarvest() func(*beego.Namespace) {
	ns := beego.NSNamespace("/harvest",
		beego.NSNamespace("/process/:process",
			beego.NSRouter("", &process.Process{}, "*:Display"),
			beego.NSNamespace("/operation/:operation",
				beego.NSRouter("", &process.Operation{}, "*:Display"),
			),
			beego.NSRouter("/history", &process.Process{}, "*:ShowHistory"),
			beego.NSRouter("/advance-options", &process.Process{}, "*:ShowAdvanceOptions"),
			beego.NSRouter("/delete", &process.Process{}, "POST:Delete"),
		),
	)
	return ns
}
Exemple #11
0
func getHarvest() func(*beego.Namespace) {
	ns := beego.NSNamespace("/harvest",
		beego.NSNamespace("/init",
			beego.NSRouter(":id", &admin.Harvest{}, "POST:ShowPanel"),
			beego.NSRouter("/ws", &admin.Harvest{}, "GET:InitWebsocketConnection"),
		),
		beego.NSNamespace("/recover",
			beego.NSRouter(":id", &admin.Harvest{}, "POST:RecoverProcess"),
		),
		beego.NSNamespace("/finish",
			beego.NSRouter(":id", &admin.Harvest{}, "POST:ForceFinishProcess"),
		),
	)
	return ns
}
Exemple #12
0
// Load tells the framework to load the addresses for the router
func Load() {
	accountNS :=
		beego.NewNamespace("/account",
			beego.NSRouter("", &account.Home{}, "GET:Show"),
			beego.NSNamespace("/searches/",
				beego.NSRouter("", &searches.List{}, "GET:Display"),
				beego.NSRouter("clear", &searches.List{}, "POST:Clear"),
			),
			beego.NSNamespace("/settings",
				beego.NSRouter("", &settings.Settings{}, "GET:Display"),
				beego.NSRouter("/delete", &settings.Settings{}, "POST:DeleteAccount"),
			),
		)
	beego.AddNamespace(accountNS)
}
Exemple #13
0
func getAuth() *beego.Namespace {
	ns := beego.NewNamespace("auth",
		beego.NSNamespace("/login",
			beego.NSRouter("", &public.Auth{}, "GET:ShowLoginPage"),
			beego.NSRouter("", &public.Auth{}, "POST:LoginAccount"),
		),
		beego.NSNamespace("/register",
			beego.NSRouter("", &public.Auth{}, "GET:ShowRegisterForm"),
			beego.NSRouter("", &public.Auth{}, "POST:CreateNewAccount"),
		),
		beego.NSNamespace("/logout",
			beego.NSRouter("", &public.Auth{}, "POST:Logout"),
		),
	)
	return ns
}
func init() {
	ns := beego.NewNamespace("/v1",
		beego.NSNamespace("/patient",
			beego.NSRouter("/:id", &controllers.PatientController{}, "get:Get"),
		),
	)
	beego.AddNamespace(ns)
}
Exemple #15
0
func getRepository() func(*beego.Namespace) {
	ns := beego.NSNamespace("/repository",
		beego.NSNamespace("/resources/:id",
			beego.NSNamespace("/get",
				beego.NSRouter("/:min/:number", &api.Repository{}, "GET:GetResources"),
			),
		),
	)
	return ns
}
Exemple #16
0
// Load tells the framework to load the addresses for the router
func Load() {

	developer :=
		beego.NewNamespace("/developer",
			beego.NSRouter("", &developer.Home{}, "GET:Display"),
			data.Get(),
			api.Get(),
			tools.Get(),
		)

	beego.AddNamespace(developer)
}
Exemple #17
0
// Get returns the namespace for institutions
func Get() *beego.Namespace {
	ns := beego.NewNamespace("/institutions",
		beego.NSRouter("", &institutions.Home{}, "*:Display"),
		beego.NSNamespace("/:institution",
			beego.NSRouter("", &institution.Institution{}, "GET:Display"),
			// program
			beego.NSNamespace("/program",
				beego.NSNamespace("/:program",
					beego.NSRouter("", &institution.Program{}, "GET:Display"),
				),
			),
			// module
			beego.NSNamespace("/module",
				beego.NSNamespace("/:module",
					beego.NSRouter("", &institution.Module{}, "GET:Display"),
				),
			),
		),
	)
	return ns
}
Exemple #18
0
func init() {
	ns := beego.NewNamespace("/v1",
		beego.NSNamespace("/admin",
			beego.NSNamespace("/t_authority",
				beego.NSInclude(
					&controllers.TAuthorityController{},
				),
			),

			beego.NSNamespace("/t_board",
				beego.NSInclude(
					&controllers.TBoardController{},
				),
			),

			beego.NSNamespace("/t_message",
				beego.NSInclude(
					&controllers.TMessageController{},
				),
			),

			beego.NSNamespace("/t_pin",
				beego.NSInclude(
					&controllers.TPinController{},
				),
			),

			beego.NSNamespace("/t_profile",
				beego.NSInclude(
					&controllers.TProfileController{},
				),
			),

			beego.NSNamespace("/t_role",
				beego.NSInclude(
					&controllers.TRoleController{},
				),
			),

			beego.NSNamespace("/t_user",
				beego.NSInclude(
					&controllers.TUserController{},
				),
			),
		),
		beego.NSRouter("/signup", &controllers.TUserController{}, "*:SignUp"),
		beego.NSRouter("/signin", &controllers.TUserController{}, "*:SignIn"),
		beego.NSRouter("/signout", &controllers.TUserController{}, "*:SignOut"),
		beego.NSRouter("/upload", &controllers.TUserController{}, "post:Upload"),
		beego.NSRouter("/recommend", &controllers.TUserController{}, "*:Recommend"),
		beego.NSRouter("/", &controllers.MainController{}, "*:Index"),
	)
	beego.AddNamespace(ns)
}
Exemple #19
0
func init() {
	beego.Router("/", &controllers.MainController{})
	ns := beego.NewNamespace("/v1",
		beego.NSNamespace("/users",
			beego.NSRouter("/register",
				&controllers.UserController{},
				"post:Register"),
			beego.NSRouter("/login",
				&controllers.UserController{},
				"post:Login"),
			beego.NSRouter("/logout",
				&controllers.UserController{},
				"post:Logout"),
			beego.NSRouter("/passwd",
				&controllers.UserController{},
				"post:Passwd"),
			beego.NSRouter("/uploads",
				&controllers.UserController{},
				"post:Uploads"),
			beego.NSRouter("/downloads",
				&controllers.UserController{},
				"get:Downloads"),
		),
		beego.NSNamespace("/roles",
			beego.NSRouter("/:id",
				&controllers.RoleController{},
				"get:GetOne;put:Put;delete:Delete"),
			beego.NSRouter("/",
				&controllers.RoleController{},
				"get:GetAll;post:Post"),
			beego.NSRouter("/auth",
				&controllers.RoleController{},
				"post:Auth"),
		),
	)
	beego.AddNamespace(ns)
}
Exemple #20
0
func init() {

	//初始化namespace

	//后台
	adminNs :=
		beego.NewNamespace("/admin",
			beego.NSAutoRouter(&admin.ArticleController{}),
		)

	//api
	apiNs :=
		beego.NewNamespace("/api",
			beego.NSRouter("/weather", &api.WeatherController{}, "get:Weather"),
		)

	//注册namespace
	beego.AddNamespace(adminNs, apiNs)

}
Exemple #21
0
// Load tells the framework to load the addresses for the router
func Load() {

	account := accounts.Get()
	curriculum := education.Get()
	developer := developers.Get()
	institutions := institutions.Get()
	harvest := getHarvest()
	log := log.Get()
	repository := repositories.Get()

	ns := beego.NewNamespace("/admin",
		beego.NSRouter("", &admin.Home{}, "*:Display"),
		account,
		curriculum,
		developer,
		institutions,
		harvest,
		log,
		repository,
	)
	beego.AddNamespace(ns)
}
Exemple #22
0
// Get returns the Namespace for the developers within administration area
func Get() func(*beego.Namespace) {

	ns := beego.NSNamespace("/developers",
		beego.NSRouter("", &developers.Home{}, "*:Display"),
		beego.NSNamespace("/add",
			beego.NSRouter("", &table.Table{}, "GET:ShowAddForm"),
			beego.NSRouter("", &table.Table{}, "POST:InsertNewTable"),
		),
		beego.NSNamespace("/table/:table",
			beego.NSNamespace("/delete",
				beego.NSRouter("", &table.Table{}, "POST:RemoveAllowedTable"),
			),
			beego.NSNamespace("/modify",
				beego.NSRouter("", &table.Table{}, "GET:ShowModifyForm"),
				beego.NSRouter("", &table.Table{}, "POST:ModifyTable"),
			),
		),
	)
	return ns

}
Exemple #23
0
func ConfigRoutes() {
	//owl-protal-routes
	dashboard := beego.NewNamespace("/api/v1/dashboard",
		beego.NSGet("/notallowed", func(ctx *context.Context) {
			ctx.Output.Body([]byte("notAllowed"))
		}),
		beego.NSRouter("/endpoints", &DashBoardController{}, "get:EndpRegxqury;post:EndpRegxqury"),
		beego.NSRouter("/endpointcounters", &DashBoardController{}, "get:CounterQuery;post:CounterQuery"),
	)
	hostgroup := beego.NewNamespace("/api/v1/hostgroup",
		beego.NSGet("/notallowed", func(ctx *context.Context) {
			ctx.Output.Body([]byte("notAllowed"))
		}),
		beego.NSRouter("/query", &DashBoardController{}, "get:HostGroupQuery;post:HostGroupQuery"),
		beego.NSRouter("/hosts", &DashBoardController{}, "get:HostsQueryByHostGroups;post:HostsQueryByHostGroups"),
		beego.NSRouter("/hostgroupscounters", &DashBoardController{}, "get:CounterQueryByHostGroup;post:CounterQueryByHostGroup"),
		beego.NSRouter("/count", &DashBoardController{}, "get:CountNumOfHostGroup;post:CountNumOfHostGroup"),
	)
	beego.Router("/ops/endpoints", &DashBoardController{}, "get:EndpRegxquryForOps")
	beego.AddNamespace(dashboard)
	beego.AddNamespace(hostgroup)
}
Exemple #24
0
func init() {
	/**
	 * https://base.jream.lu/v1/url/goshorten.json
	 * https://base.jream.lu/v1/url/goexpand.json
	 */
	base := beego.NewNamespace("/v1",
		beego.NSCond(func(ctx *context.Context) bool {
			if ctx.Input.Domain() == beego.AppConfig.String("baseDomain") {
				return true
			}
			return false
		}),
		beego.NSNamespace("url",
			beego.NSRouter("/goshorten.json", &controllers.UrlController{}, "post:GoShorten"),
			beego.NSRouter("/goshorten", &controllers.UrlController{}, "post:GoShorten"),
			beego.NSRouter("/goexpand.json", &controllers.UrlController{}, "post:GoExpand"),
			beego.NSRouter("/goexpand", &controllers.UrlController{}, "post:GoExpand"),
		),
		beego.NSRouter("/object", &controllers.ObjectController{}, "post:Post"),
		beego.NSRouter("/test", &controllers.TesController{}, "post:Post"),
	)

	beego.AddNamespace(base)
}
Exemple #25
0
func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/login", &controllers.MainController{}, "get:LoginPage")
	beego.Router("/validUser", &controllers.MainController{}, "post:ValidUser")
	beego.Router("/author", &controllers.UserControlelr{}, "get:Author")
	nsApi :=
		beego.NewNamespace("/i",
			beego.NSRouter("/posts", &controllers.PostController{}, "get:Posts"),
			beego.NSRouter("/posts/list/:page", &controllers.PostController{}, "get:ListPosts"),
			beego.NSRouter("/posts/:id", &controllers.PostController{}, "get:OnePost"),
			beego.NSRouter("/submitMsg", &controllers.PostController{}, "post:SubmitMsg"),
		)
	beego.AddNamespace(nsApi)

	nsAdmin :=
		beego.NewNamespace("admin",
			beego.NSRouter("/main", &controllers.MainController{}, "get:Main"),
			beego.NSRouter("/logout", &controllers.MainController{}, "get:Logout"),
			beego.NSRouter("/user", &controllers.MainController{}, "get:UserPage"),
			beego.NSRouter("/userUpdate", &controllers.MainController{}, "post:UserUpdate"),
			beego.NSRouter("/post", &controllers.MainController{}, "get:PostPage"),
			beego.NSRouter("/post/save", &controllers.MainController{}, "post:SavePost"),
			beego.NSRouter("/post/delete/:id", &controllers.MainController{}, "delete:DeletePost"),
			beego.NSRouter("/message", &controllers.MainController{}, "get:MessagePage"),
			beego.NSRouter("/message/list/:page", &controllers.MainController{}, "get:ListMessage"),
			beego.NSRouter("/message/delete/:id", &controllers.MainController{}, "delete:DeleteMessage"),
			beego.NSRouter("/message/reply", &controllers.MainController{}, "post:ReplyMessage"),
			beego.NSRouter("/write", &controllers.MainController{}, "get:WritePage"),
			beego.NSRouter("/imgUp", &controllers.MainController{}, "post:ImgUp"),
			beego.NSRouter("/resetPwd", &controllers.MainController{}, "post:ResetPwd"),
		)
	beego.AddNamespace(nsAdmin)

	var checkUser = func(ctx *context.Context) {
		if strings.HasPrefix(ctx.Request.RequestURI, "/admin") {
			_, ok := ctx.Input.Session("inote").(int)
			if !ok && ctx.Request.RequestURI != "/login" {
				ctx.Redirect(302, "/login")
			}
		}
	}
	beego.InsertFilter("/*", beego.BeforeRouter, checkUser)
}
Exemple #26
0
func init() {
	beego.Router("/", &controllers.MainController{})
	ns :=
		beego.NewNamespace("/api",
			beego.NSNamespace("/v1",
				//books
				beego.NSRouter("/books", &controllers.BooksController{}, "get:showAllBooks"),
				beego.NSRouter("/books", &controllers.BooksController{}, "post:addBook"),
				beego.NSRouter("/books/:bookId([0-9]+)", &controllers.BooksController{}, "get:showBook"),
				beego.NSRouter("/books/:bookId([0-9]+)", &controllers.BooksController{}, "put:updateBook"),
				beego.NSRouter("/books/:bookId([0-9]+)", &controllers.BooksController{}, "delete:deleteBook"),
				//libraries
				beego.NSRouter("/libraries", &controllers.LibraryController{}, "get:showAllLibraries"),
				beego.NSRouter("/libraries", &controllers.LibraryController{}, "post:addLibrary"),
				beego.NSRouter("/libraries/:libId([0-9]+)", &controllers.LibraryController{}, "get:listBooksInLibrary"),
				beego.NSRouter("/libraries/:libId([0-9]+)/:bookId([0-9]+)", &controllers.LibraryController{}, "post:addBookInLibrary"),
				beego.NSRouter("/libraries/:libId([0-9]+)", &controllers.LibraryController{}, "put:updateLibrary"),
				beego.NSRouter("/libraries/:libId([0-9]+)", &controllers.LibraryController{}, "delete:deleteLibrary"),
			),
		)

	//register namespace
	beego.AddNamespace(ns)
}
Exemple #27
0
func router() {
	authR := beego.NewNamespace("/auth",
		beego.NSCond(func(ctx *context.Context) bool {
			if ctx.Input.Domain() == "api.beego.me" {
				return true
			}
			commonFilter(ctx)
			return true
		}),
		// beego.NSBefore(func(ctx *context.Context) {
		// beego.Debug("path=>", ctx.Request.URL.Path)
		// services.etInstance().AuthService.WithContext(ctx, func() {
		// if services.GetInstance().AuthService.HasLogin() {
		// ctx.Redirect(200, "/admin/index")
		// }
		// })
		// }),
		beego.NSRouter("/login", &controllers.AuthController{}, "*:Login"),
		beego.NSRouter("/logout", &controllers.AuthController{}, "*:Logout"),
	)

	adminR := beego.NewNamespace("/admin",
		beego.NSBefore(func(ctx *context.Context) {
			commonFilter(ctx)
			services.GetInstance().AuthService.WithContext(ctx, func() {
				if !services.GetInstance().AuthService.HasLogin() {
					ctx.Redirect(302, "/auth/login")
				}
			})
		}),
		beego.NSRouter("/index", &controllers.AdminController{}, "*:Index"),
		beego.NSNamespace("/user",
			beego.NSGet("/info/:id", func(ctx *context.Context) {
				ctx.Output.Body([]byte("shopinfo"))
			}),
			beego.NSRouter("/list", &controllers.AdminController{}, "Get:UserList"),
			beego.NSRouter("/operate/?:userId", &controllers.AdminController{}, "*:UserOperate"),
			beego.NSRouter("/delete/:userId", &controllers.AdminController{}, "Get:UserDelete"),
		),
		beego.NSNamespace("/agent",
			beego.NSRouter("/list", &controllers.AdminController{}, "Get:AgentList"),
			beego.NSRouter("/operate/?:agentId", &controllers.AdminController{}, "*:AgentOperate"),
			beego.NSRouter("/delete/:agentId", &controllers.AdminController{}, "Get:AgentDelete"),
			beego.NSRouter("/:agentId/cmd/list", &controllers.AdminController{}, "Get:CmdList"),
			beego.NSRouter("/:agentId/cmd/operate", &controllers.AdminController{}, "*:CmdOperate"),
			beego.NSRouter("/:agentId/cmd/operate/?:cmdId", &controllers.AdminController{}, "*:CmdOperate"),
			beego.NSRouter("/cmd/delete/:cmdId", &controllers.AdminController{}, "Get:CmdDelete"),
		),
		beego.NSNamespace("/ssh",
			beego.NSRouter("/:agentId", &controllers.AdminController{}, "Get:SshIndex"),
			beego.NSRouter("/join/:agentId", &controllers.AdminController{}, "*:SshJoin"),
			beego.NSRouter("/list", &controllers.AdminController{}, "*:SshList"),
		),
		beego.NSNamespace("/server",
			beego.NSRouter("/index/?:serverId", &controllers.ServerController{}, "Get:Index"),
			beego.NSRouter("/operate/?:serverId", &controllers.ServerController{}, "*:Operate"),
			beego.NSRouter("/delete/:serverId", &controllers.ServerController{}, "Get:Delete"),
		),
	)

	guestR := beego.NewNamespace("/guest",
		beego.NSBefore(func(ctx *context.Context) {
			commonFilter(ctx)
		}),
		beego.NSNamespace("/server",
			beego.NSRouter("/share/:serverId", &controllers.ServerController{}, "Get:Share"),
			beego.NSRouter("/:serverId/active/:apiParamId", &controllers.ServerController{}, "*:Active"),
			beego.NSRouter("/:serverId/encode/:apiParamId", &controllers.ServerController{}, "Post:Encode"),
			beego.NSRouter("/info", &controllers.ServerController{}, "Get:Info"),
		),
	)

	//注册namespace
	beego.AddNamespace(authR, adminR, guestR)

}
Exemple #28
0
// Get returns the namespace for institutions
func Get() func(*beego.Namespace) {

	ns := beego.NSNamespace("/repositories",
		beego.NSRouter("", &repositories.Home{}, "*:Display"),
		beego.NSNamespace("/add",
			beego.NSRouter("", &repository.Repository{}, "GET:ShowChooseCategory"),
		),
		beego.NSNamespace("/newRepository",
			beego.NSRouter("", &repository.Repository{}, "GET:ShowInsertForm"),
			beego.NSRouter("", &repository.Repository{}, "POST:Insert"),
		),
		beego.NSNamespace("/:repository",
			beego.NSRouter("", &repository.Repository{}, "GET:Display"),
			beego.NSNamespace("/advance-options",
				beego.NSRouter("", &repository.Repository{}, "GET:ShowAdvanceOptions"),
				beego.NSNamespace("/modify",
					beego.NSRouter("", &repository.Repository{}, "GET:ShowModifyForm"),
					beego.NSRouter("", &repository.Repository{}, "POST:Modify"),
					beego.NSNamespace("/filter",
						beego.NSRouter("", &repository.Repository{}, "GET:ShowFilterForm"),
						beego.NSRouter("", &repository.Repository{}, "POST:ModifyFilter"),
					),
				),
			),
			beego.NSNamespace("/clear",
				beego.NSRouter("", &repository.Repository{}, "POST:ClearRepository"),
			),
			beego.NSNamespace("/delete",
				beego.NSRouter("", &repository.Repository{}, "POST:Delete"),
			),
		),
	)
	return ns
}
Exemple #29
0
func init() {
	loginC := &controllers.LoginController{}
	login := beego.NewNamespace("/login",
		beego.NSRouter("/", loginC, "get:Login"),
		beego.NSRouter("/in", loginC, "post:DoLogin"),
		beego.NSRouter("/out", loginC, "get,post:LoginOut"),
	)
	tsC := &controllers.TSController{}
	ts := beego.NewNamespace("/ts",
		beego.NSRouter("/php", tsC, "get:PHP"),
		beego.NSRouter("/js", tsC, "get:JS"),
		beego.NSRouter("/", tsC, "get:Get"),
		beego.NSRouter("/more", tsC, "get:More"),
		beego.NSRouter("/ajax", tsC, "get:AjaxGet"),
		beego.NSRouter("/post", tsC, "get,post:Post"),
	)
	tsklC := &controllers.TSKLController{}
	tskl := beego.NewNamespace("/tskl",
		beego.NSRouter("/", tsklC, "get:Get"),
		beego.NSRouter("/ajax", tsklC, "get:AjaxGet"),
		beego.NSRouter("/post", tsklC, "get,post:Post"),
		beego.NSRouter("/getkl", tsklC, "get,post:GetKL"),
		beego.NSRouter("/postkl", tsklC, "get,post:PostKL"),
	)
	userC := &controllers.UserController{}
	user := beego.NewNamespace("/user",
		beego.NSRouter("/", userC, "get:Show"),
		beego.NSRouter("/create", userC, "post:Create"),
		beego.NSRouter("/update", userC, "post:Update"),
		beego.NSRouter("/delete", userC, "post:Delete"),
	)
	sqC := &controllers.SQController{}
	sq := beego.NewNamespace("/sq",
		beego.NSRouter("/", sqC, "get:Show"),
		beego.NSRouter("/post", sqC, "post:Create"),
		beego.NSRouter("/admin", sqC, "get:AdminShow"),
		beego.NSRouter("/status", sqC, "post:AdminStatus"),
	)
	beego.AddNamespace(login, user, ts, tskl, sq)
}
Exemple #30
0
func ConfigRoutes() {

	beego.Router("/root", &UserController{}, "get:CreateRoot")

	beego.Router("/auth/login", &AuthController{}, "get:LoginGet;post:LoginPost")
	beego.Router("/auth/register", &AuthController{}, "get:RegisterGet;post:RegisterPost")

	beego.Router("/sso/sig", &SsoController{}, "get:Sig")
	beego.Router("/sso/user/:sig:string", &SsoController{}, "get:User")
	beego.Router("/sso/logout/:sig:string", &SsoController{}, "get:Logout")

	beego.Router("/user/query", &UserController{}, "get:Query")
	beego.Router("/user/in", &UserController{}, "get:In")
	beego.Router("/user/qrcode/:id:int", &UserController{}, "get:QrCode")
	beego.Router("/about/:name:string", &UserController{}, "get:About")

	beego.Router("/team/users", &TeamController{}, "get:Users")
	beego.Router("/team/query", &TeamController{}, "get:Query")
	beego.Router("/team/all", &TeamController{}, "get:All")

	loginRequired :=
		beego.NewNamespace("/me",
			beego.NSCond(func(ctx *context.Context) bool {
				return true
			}),
			beego.NSBefore(base.FilterLoginUser),
			beego.NSRouter("/logout", &AuthController{}, "*:Logout"),
			beego.NSRouter("/info", &UserController{}, "get:Info"),
			beego.NSRouter("/profile", &UserController{}, "get:ProfileGet;post:ProfilePost"),
			beego.NSRouter("/chpwd", &UserController{}, "*:ChangePassword"),
			beego.NSRouter("/users", &UserController{}, "get:Users"),
			beego.NSRouter("/user/c", &UserController{}, "get:CreateUserGet;post:CreateUserPost"),
			beego.NSRouter("/teams", &TeamController{}, "get:Teams"),
			beego.NSRouter("/team/c", &TeamController{}, "get:CreateTeamGet;post:CreateTeamPost"),
		)

	beego.AddNamespace(loginRequired)

	targetUserRequired :=
		beego.NewNamespace("/target-user",
			beego.NSCond(func(ctx *context.Context) bool {
				return true
			}),
			beego.NSBefore(base.FilterLoginUser, base.FilterTargetUser),
			beego.NSRouter("/delete", &UserController{}, "*:DeleteUser"),
			beego.NSRouter("/edit", &UserController{}, "get:EditGet;post:EditPost"),
			beego.NSRouter("/chpwd", &UserController{}, "post:ResetPassword"),
			beego.NSRouter("/role", &UserController{}, "*:Role"),
		)

	beego.AddNamespace(targetUserRequired)

	targetTeamRequired :=
		beego.NewNamespace("/target-team",
			beego.NSCond(func(ctx *context.Context) bool {
				return true
			}),
			beego.NSBefore(base.FilterLoginUser, base.FilterTargetTeam),
			beego.NSRouter("/delete", &TeamController{}, "*:DeleteTeam"),
			beego.NSRouter("/edit", &TeamController{}, "get:EditGet;post:EditPost"),
		)

	beego.AddNamespace(targetTeamRequired)

}