Ejemplo n.º 1
0
func GetUserMe(w http.ResponseWriter, r *http.Request, c *server.Context) {
	id := c.Session.UserId
	user := models.GetUserById(c.DB.DB, id)
	if user != nil {
		c.Render.ResultOK(w, user)
	} else {
		c.Render.NotFound(w)
	}
}
Ejemplo n.º 2
0
func GetUser(w http.ResponseWriter, r *http.Request, c *server.Context) {
	id := c.PathParams["id"]
	userId, err := strconv.Atoi(id)
	if err != nil {
		c.Render.NotFound(w)
		return
	}

	user := models.GetUserById(c.DB.DB, userId)
	if user != nil {
		c.Render.ResultOK(w, user)
	} else {
		c.Render.NotFound(w)
	}
}