本文整理匯總了Golang中github.com/gin-gonic/gin.RouterGroup類的典型用法代碼示例。如果您正苦於以下問題:Golang RouterGroup類的具體用法?Golang RouterGroup怎麽用?Golang RouterGroup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RouterGroup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: api
func api(api *gin.RouterGroup) {
api.POST("/point", func(c *gin.Context) {
p := point.Point{}
err := c.Bind(&p)
hash, err := hash.NewHashPoint(p)
if err != nil || !p.IsValid() {
c.JSON(http.StatusBadRequest, "Invalid point")
} else {
c.JSON(http.StatusOK, gin.H{
"point": p,
"hash": reverseString(hash.String),
"zorder": reverseString(hash.GetZorder().HashString(32)),
})
}
})
api.POST("/hash", func(c *gin.Context) {
hash := &hash.Hash{}
err := c.Bind(&hash)
hash.String = reverseString(hash.String)
if err != nil || hash.InitFromString() != nil {
c.JSON(http.StatusBadRequest, "Invalid hash")
} else {
c.JSON(http.StatusOK, gin.H{
"hash": reverseString(hash.String),
"point": hash.GenPoint(),
"zorder": reverseString(hash.GetZorder().HashString(32)),
})
}
})
}
示例2: SetupMiddlewares
func SetupMiddlewares(group *gin.RouterGroup) {
if command.Opts.Debug {
group.Use(requestInspectMiddleware())
}
group.Use(dbCheckMiddleware())
}
示例3: Users
// @Title Users
// @Description Users's router group.
func Users(parentRoute *gin.RouterGroup) {
route := parentRoute.Group("/users")
route.POST("", createUser)
route.GET("/:id", retrieveUser)
route.GET("", retrieveUsers)
route.PUT("/:id", userPermission.AuthRequired(updateUser))
route.DELETE("/:id", userPermission.AuthRequired(deleteUser))
route.POST("/roles", userPermission.AdminRequired(addRoleToUser))
route.DELETE(":id/roles/:roleId", userPermission.AdminRequired(removeRoleFromUser))
route.POST("/likings", userPermission.AuthRequired(createLikingOnUser))
route.GET("/:id/likings", retrieveLikingsOnUsers)
route.DELETE("/:id/likings/:userId", userPermission.AuthRequired(deleteLikingOnUser))
route.GET("/:id/liked", retrieveLikedOnUsers)
route = parentRoute.Group("/user")
route.GET("/current", retrieveCurrentUser)
route.POST("/send/password/reset/token", sendPasswordResetToken)
route.PUT("/reset/password", resetPassword)
route.POST("/send/email/verification/token", sendEmailVerificationToken)
route.PUT("/verify/email", verifyEmail)
route.GET("/email/:email", retrieveUserByEmail)
route.GET("/email/:email/list", retrieveUsersByEmail)
route.GET("/username/:username", retrieveUserByUsername)
route.GET("/admin/:id", userPermission.AdminRequired(retrieveUserForAdmin))
route.GET("/admin", userPermission.AdminRequired(retrieveUsersForAdmin))
route.PUT("/activate/:id", userPermission.AdminRequired(activateUser))
route.GET("/test/send/email", sendTestEmail)
}
示例4: GetGroupHandler
func GetGroupHandler(router *gin.RouterGroup) {
admin := router.Group("/admin").Use(jwt.GinJwtHandler).Use(jwt.GroupHandler("admin"))
{
admin.GET("/:prop", getProperty)
admin.PUT("/:prop", setProperty)
}
}
示例5: Person
func Person(router *gin.RouterGroup) {
router.GET("/persons", handler.GetAll)
router.GET("/person/:id", handler.GetById)
router.POST("/person", handler.Create)
router.PUT("/person", handler.Update)
router.DELETE("/person", handler.Delete)
}
示例6: Register
func (u *UserResource) Register(usergroup *gin.RouterGroup) {
usergroup.OPTIONS("login")
usergroup.GET("login", u.login)
usergroup.GET("find/:user-id", u.findUser)
usergroup.PUT("update/:user-id", u.updateUser)
usergroup.DELETE("remove/:user-id", u.removeUser)
}
示例7: Routes
func Routes(oauth *oauth2.Config, r *gin.RouterGroup) {
passportOauth = oauth
r.GET("/login", func(c *gin.Context) {
Login(oauth, c)
})
}
示例8: Roles
// @Title Roles
// @Description Roles's router group.
func Roles(parentRoute *gin.RouterGroup) {
route := parentRoute.Group("/roles")
route.POST("", userPermission.AdminRequired(createRole))
route.GET("/:id", retrieveRole)
route.GET("", retrieveRoles)
route.PUT("/:id", userPermission.AdminRequired(updateRole))
route.DELETE("/:id", userPermission.AdminRequired(deleteRole))
}
示例9: Routes
// set up the admin Routes, and add in the Authenticator middleware if present
func Routes(r *gin.RouterGroup) {
// root level is list of admin models
r.Handle("GET", "/", index)
r.Handle("GET", "/:model/", list)
r.Handle("POST", "/:model/", listUpdate)
r.Handle("GET", "/:model/:pk", change)
r.Handle("POST", "/:model/:pk", changeUpdate)
}
示例10: NewSshController
func NewSshController(s *gin.RouterGroup) *SshController {
ctl := &SshController{}
s.GET("/ssh/public-key", ctl.getPublicKey)
return ctl
}
示例11: taskRoutes
func taskRoutes(api *gin.RouterGroup, prefix string) {
g := api.Group(prefix)
{
g.DELETE(":id", deleteTask)
g.PUT(":id/move/:new_list_id", moveTask)
}
}
示例12: BindRoutes
// BindRoutes bind this package's routes to the given gin.RouterGroup at the given base URI.
func BindRoutes(baseRouter *gin.RouterGroup, baseURI string) {
router := baseRouter.Group(baseURI)
// Register routes.
router.Use(common.BasicAuthRequired) // Protect these resources with basic auth.
router.GET("/builds/", GetElasticsearchBuilds)
router.POST("/builds/", common.BindJSON(&BuildModel{}), CreateElasticsearchBuild)
router.GET("/builds/:id", GetElasticsearchBuildByID)
}
示例13: Setup
// Setup will setup all API routes.
func Setup(group *gin.RouterGroup, db *db.DB) {
group.Use()
{
group.GET("/items/:code", itemsShowHandler(db))
group.DELETE("/items/:code", itemsDestroyHandler(db))
group.GET("/items", itemsIndexHandler(db))
group.POST("/items", itemsCreateHandler(db))
}
}
示例14: NewDeploymentController
func NewDeploymentController(s *gin.RouterGroup) *DeploymentController {
ctl := &DeploymentController{}
s.GET("/apps/:id/deploy/:deploy_id", ctl.getDeployment)
s.GET("/apps/:id/deploy", ctl.getDeploymentList)
return ctl
}
示例15: Upload
// @Title Upload
// @Description Upload's router group.
func Upload(parentRoute *gin.RouterGroup) {
route := parentRoute.Group("/upload")
route.POST("/images", userPermission.AuthRequired(uploadImages))
route.POST("/files", userPermission.AuthRequired(createFile))
route.POST("/files/all", userPermission.AuthRequired(createFiles))
route.GET("/files/:id", retrieveFile)
route.GET("/files", retrieveFiles)
route.PUT("/files/:id", userPermission.AuthRequired(updateFile))
route.DELETE("/files/:id", userPermission.AuthRequired(deleteFile))
}