Exemplo n.º 1
0
// @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)
}
Exemplo n.º 2
-5
// @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))
}