Example #1
0
File: home.go Project: Gr1N/pacman
// Home returns context for front-end initialization.
func Home(c *gin.Context) {
	user := middleware.UserFromContext(c)

	c.JSON(http.StatusOK, gin.H{
		"user": gin.H{
			"id": user.ID,
		},
	})
}
Example #2
0
File: repos.go Project: Gr1N/pacman
// ReposList returns list of user repos for specified service.
func ReposList(c *gin.Context) {
	service := c.Param("service")
	if err := oauth2.HandleService(service); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{})
		return
	}

	user := middleware.UserFromContext(c)
	repos, _ := models.GetUserReposByService(user.ID, service)

	c.JSON(http.StatusOK, gin.H{
		"list":  repos,
		"total": len(repos),
	})
}