當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Router.Group方法代碼示例

本文整理匯總了Golang中github.com/go-martini/martini.Router.Group方法的典型用法代碼示例。如果您正苦於以下問題:Golang Router.Group方法的具體用法?Golang Router.Group怎麽用?Golang Router.Group使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/go-martini/martini.Router的用法示例。


在下文中一共展示了Router.Group方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AddRoutes

func AddRoutes(r martini.Router) {
	r.Group("/api/v1", func(r martini.Router) {
		addNeedRoutes(r)
		addResourceRoutes(r)
		addStaffRoutes(r)
	}, MapCodec)
}
開發者ID:riannucci,項目名稱:fish_basket,代碼行數:7,代碼來源:routes.go

示例2: addStaffRoutes

func addStaffRoutes(r martini.Router) {
	r.Group("/staff", func(r martini.Router) {
		r.Get("", func() string {
			return "Staff stuff?"
		})
	}, ensureStaffMember)
}
開發者ID:riannucci,項目名稱:fish_basket,代碼行數:7,代碼來源:staff.go

示例3: initCurrencyApi

func initCurrencyApi(r martini.Router) {
	r.Group("/currencies", func(r martini.Router) {
		r.Get("", func() string {
			var _, body, _ = request.Get("http://api.fixer.io/latest?base=USD").End()
			return body
		})
	})
}
開發者ID:lugovsky,項目名稱:angular-go-seed,代碼行數:8,代碼來源:currencies.go

示例4: InitApplicationsRoutes

func InitApplicationsRoutes(r martini.Router) {
	r.Group("/admin/applications", func(router martini.Router) {
		router.Get("/get/:id", getApplication)
		router.Get("/list", getApplications)
		router.Post("/create", createApplications)
		router.Post("/update", updateApplications)
		router.Post("/delete/:id", deleteApplication)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:9,代碼來源:applications.go

示例5: InitUsersRoutes

func InitUsersRoutes(r martini.Router) {
	r.Group("/admin/users", func(router martini.Router) {
		router.Get("/get/:id", getUser)
		router.Get("/list", getUsers)
		router.Get("/get/:id/roles/application/:appId", getUserRoles)
		router.Post("/create", createUsers)
		router.Post("/update", updateUsers)
		router.Post("/delete/:id", deleteUser)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:10,代碼來源:users.go

示例6: addNeedRoutes

func addNeedRoutes(r martini.Router) {
	r.Group("/needs", func(r martini.Router) {
		r.Get("", func() string {
			return "All my needs"
		})
		r.Get("/:id", func(p martini.Params) string {
			return "Need(" + p["id"] + ")"
		})
	})
}
開發者ID:riannucci,項目名稱:fish_basket,代碼行數:10,代碼來源:need.go

示例7: InitRolesRoutes

func InitRolesRoutes(r martini.Router) {
	r.Group("/admin/roles", func(router martini.Router) {
		router.Get("/get/:id", getRole)
		router.Get("/list", getRoles)
		router.Get("/application/:appId", getRolesByApplication)
		router.Post("/create", createRoles)
		router.Post("/update", updateRoles)
		router.Post("/delete/:id", deleteRole)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:10,代碼來源:roles.go

示例8: InitGroupsRoutes

func InitGroupsRoutes(r martini.Router) {
	r.Group("/admin/groups", func(router martini.Router) {
		router.Get("/get/:id", getGroup)
		router.Get("/list", getGroups)
		router.Get("/application/:appId", getGroupsByApplication)
		router.Post("/create", createGroups)
		router.Post("/update", updateGroups)
		router.Post("/delete/:id", deleteGroup)
	})
}
開發者ID:jcgarciam,項目名稱:go-wasab,代碼行數:10,代碼來源:groups.go

示例9: AdminRoute

// AdminRoute manages routing for Restful API
func AdminRoute(r martini.Router) {
	r.Get("/rest/metadata", AdminGetModels)
	r.Get("/rest/metadata/:modelName", AdminGetMetaData)
	r.Group("/rest/:modelName", func(restRoutes martini.Router) {
		restRoutes.Get("", AdminGetList)
		restRoutes.Get("/:id", AdminGetEntity)
		restRoutes.Post("", AdminNewEntity)
		restRoutes.Put("/:id", AdminUpdateEntity)
		restRoutes.Delete("/:id", AdminDeleteEntity)
	})
	r.Get("/", AdminIndex)
}
開發者ID:ronlobo,項目名稱:gae-go-starter-martini,代碼行數:13,代碼來源:admin.go

示例10: Register

func (us UserService) Register(router martini.Router) {
	utils.Log.Debug("Registering UserService!")

	router.Group("/users", func(rtr martini.Router) {
		rtr.Post("", PreventReauth, binding.Bind(models.User{}), us.Create)
		rtr.Post("/update", EnsureAuth, binding.Bind(models.User{}), us.Update)
	})

	router.Get("/signout", us.SignOut)
	router.Get("/signup", PreventReauth, us.SignUp)
	router.Get("/signin", PreventReauth, us.SignIn)
	router.Get("/dashboard", EnsureAuth, us.Dashboard)
	router.Get("/settings/edit", EnsureAuth, us.Edit)
	router.Get("/settings/edit/:category", EnsureAuth, us.Edit)
	router.Get("/wakatime/sync", EnsureAuth, us.SyncHeartbeats)
}
開發者ID:gophergala2016,項目名稱:chroniton,代碼行數:16,代碼來源:user_service.go

示例11: Register

func (ps ProjectService) Register(router martini.Router) {
	router.Group("/projects", func(rtr martini.Router) {
		rtr.Get("/new", ps.New)
		rtr.Post("", binding.Bind(models.Project{}), ps.Create)
	}, EnsureAuth)
}
開發者ID:gophergala2016,項目名稱:chroniton,代碼行數:6,代碼來源:projects.go

示例12: initBooksApi

func initBooksApi(r martini.Router) {
	r.Group("/books", func(r martini.Router) {
		r.Get("", getBooks)
	})
}
開發者ID:lugovsky,項目名稱:angular-go-seed,代碼行數:5,代碼來源:books.go

示例13: BindRoutes

// BindRoutes binds API routes.
func BindRoutes(r martini.Router) {

	r.NotFound(func(req *http.Request, r render.Render) {
		r.JSON(http.StatusNotFound, []string{"The requested url does not exists."})
	})

	r.Get("/api/status", Status)

	// Registration
	r.Group("/api", func(r martini.Router) {
		r.Group("/accounts", func(r martini.Router) {
			r.Post("/register", binding.Bind(accounts.RegisterViewModel{}), NotificatorHandler(), accounts.Register)
		})
	}, GatekeeperRouteHandler())

	// DASHBOARD GATEKEEPER
	r.Group("/api", func(r martini.Router) {
		r.Group("/auth", func(r martini.Router) {
			r.Post("/password", binding.Bind(auth.PasswordRequest{}), auth.Password)
		})
	}, GatekeeperRouteHandler(), AccountScopeHandler(), RepositoryScopeHandler())

	//ADMIN
	r.Group("/api", func(r martini.Router) {
		r.Get("/accounts", accounts.Index)
		r.Post("/accounts", binding.Bind(accounts.AccountViewModel{}), accounts.Post)
		r.Delete("/:id", accounts.Delete)
	}, AdminRouteHandler())

	//Owner / Manager
	r.Group("/api", func(r martini.Router) {
		r.Group("/accounts", func(r martini.Router) {
			r.Get("/:id", accounts.Get)
			r.Put("/:id", binding.Bind(accounts.AccountViewModel{}), accounts.Put)
		})

		r.Get("/devices", devices.Index)
		r.Post("/devices", binding.Bind(devices.DeviceViewModel{}), devices.Post)
		r.Group("/devices", func(r martini.Router) {
			r.Get("/:id", devices.Get)
			r.Put("/:id", binding.Bind(devices.DeviceViewModel{}), devices.Put)
			r.Post("/register", binding.Bind(devices.DeviceViewModel{}), devices.Post)
			r.Delete("/:id", devices.Delete)
		})

		r.Get("/doors", doors.Index)
		r.Post("/doors", binding.Bind(doors.DoorViewModel{}), doors.Post)
		r.Group("/doors", func(r martini.Router) {
			r.Get("/:id", doors.Get)
			r.Put("/:id", binding.Bind(doors.DoorViewModel{}), doors.Put)
			r.Delete("/:id", doors.Delete)
		})

		r.Post("/people", binding.Bind(people.PersonViewModel{}), people.Post)
		r.Group("/people", func(r martini.Router) {
			r.Post("/sync", BridgeHandler(), people.Sync)
			r.Delete("/:id", people.Delete)
		})

	}, AccountScopeHandler(), RepositoryScopeHandler(), SecuredRouteHandler(), ManagerRestrictedRouteHandler())

	//Account
	r.Group("/api", func(r martini.Router) {
		r.Group("/accounts", func(r martini.Router) {
			r.Get("/:id", accounts.Get)
		})

		r.Post("/notifications", NotificatorHandler(), binding.Bind(notifications.ViewModel{}), notifications.Notify)

		r.Get("/people", people.Index)
		r.Group("/people", func(r martini.Router) {
			r.Get("/:id", people.Get)
			r.Put("/:id", binding.Bind(people.PersonViewModel{}), people.Put)
		})

	}, AccountScopeHandler(), RepositoryScopeHandler(), SecuredRouteHandler())
}
開發者ID:masom,項目名稱:doorbot,代碼行數:78,代碼來源:routes.go

示例14: EnsureWorkWithUsers

func EnsureWorkWithUsers(r martini.Router, db *d.MainDb) martini.Router {
	r.Group("/users", func(r martini.Router) {
		r.Get("", w.LoginRequired, w.AutHandler.CheckIncludeAnyRole(MANAGER), func(r render.Render, req *http.Request) {
			r.HTML(200, "users", w.AddCurrentUser(GetUsersInfo("", db), req, db), render.HTMLOptions{Layout: "base"})
		})

		r.Post("/add", w.LoginRequired, w.AutHandler.CheckIncludeAnyRole(MANAGER), func(r render.Render, request *http.Request) {
			u_id := strings.TrimSpace(request.FormValue("user-id"))
			u_name := strings.TrimSpace(request.FormValue("user-name"))
			u_phone := request.FormValue("user-phone")
			u_email := request.FormValue("user-e-mail")
			u_role := strings.TrimSpace(request.FormValue("user-role"))
			u_pwd := request.FormValue("user-pwd")
			u_read_rights := strings.Fields(request.FormValue("read-rights"))
			u_write_rights := strings.Fields(request.FormValue("write-rights"))
			u_belongs_to := strings.TrimSpace(request.FormValue("belongs-to"))

			log.Printf("CONSOLE WEB add user [%s]  '%s' +%s %s |%v| {%s}", u_id, u_name, u_phone, u_email, u_role, u_pwd)
			if u_name != "" && u_id != "" {
				db.Users.AddOrUpdateUserObject(d.UserData{
					UserId:      u_id,
					UserName:    u_name,
					Email:       u_email,
					Phone:       u_phone,
					Role:        u_role,
					Password:    u.PHash(u_pwd),
					LastUpdate:  time.Now(),
					ReadRights:  u_read_rights,
					WriteRights: u_write_rights,
					BelongsTo:   u_belongs_to,
				})
				r.Redirect("/users")
			} else {
				r.HTML(200,
					"users",
					w.AddCurrentUser(GetUsersInfo("Невалидные значения имени и (или) идентификатора добавляемого пользователя", db), request, db),
					render.HTMLOptions{Layout: "base"})
			}
		})

		r.Post("/delete/:id", w.LoginRequired, w.AutHandler.CheckIncludeAnyRole(MANAGER), func(params martini.Params, render render.Render) {
			uid := params["id"]
			err := db.Users.UsersCollection.Remove(bson.M{"user_id": uid})
			log.Printf("CONSOLE WEB will delete user %v (%v)", uid, err)
			render.Redirect("/users")
		})

		r.Post("/update/:id", w.LoginRequired, w.AutHandler.CheckIncludeAnyRole(MANAGER), func(params martini.Params, render render.Render, request *http.Request) {
			u_id := params["id"]
			u_name := strings.TrimSpace(request.FormValue("user-name"))
			u_phone := request.FormValue("user-phone")
			u_email := request.FormValue("user-e-mail")
			u_role := request.FormValue("user-role")
			u_pwd := request.FormValue("user-pwd")
			u_read_rights := strings.Fields(request.FormValue("read-rights"))
			u_write_rights := strings.Fields(request.FormValue("write-rights"))
			u_belongs_to := strings.TrimSpace(request.FormValue("belongs-to"))

			upd := bson.M{}
			if u_name != "" {
				upd["user_name"] = u_name
			}
			if u_email != "" {
				upd["email"] = u_email
			}
			if u_phone != "" {
				upd["phone"] = u_phone
			}
			if u_role != "" {
				upd["role"] = u_role
			}
			if u_pwd != "" {
				upd["password"] = u.PHash(u_pwd)
			}
			if len(u_read_rights) > 0 {
				upd["read_rights"] = u_read_rights
			}
			if len(u_write_rights) > 0 {
				upd["write_rights"] = u_write_rights
			}
			if u_belongs_to != "" {
				upd["belongs_to"] = u_belongs_to
			}
			db.Users.UsersCollection.Update(bson.M{"user_id": u_id}, bson.M{"$set": upd})
			log.Printf("CONSOLE WEB update user [%s]  '%s' +%s %s |%v| {%v}", u_id, u_name, u_phone, u_email, u_role, u_pwd)
			render.Redirect("/users")
		})
	})
	return r
}
開發者ID:AlexeyProskuryakov,項目名稱:kukuau_api_bot,代碼行數:90,代碼來源:Views.go


注:本文中的github.com/go-martini/martini.Router.Group方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。