server/users.go
raw| 1 | package server |
| 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | |
| 6 | "github.com/gin-gonic/gin" |
| 7 | ) |
| 8 | |
| 9 | func (s *Server) handleGetUsers() gin.HandlerFunc { |
| 10 | return func(c *gin.Context) { |
| 11 | user, err := s.b.GetUser(c.GetString("UserID")) |
| 12 | if err != nil { |
| 13 | c.AbortWithStatus(http.StatusInternalServerError) |
| 14 | return |
| 15 | } |
| 16 | |
| 17 | c.JSON(http.StatusOK, gin.H{ |
| 18 | "User": user, |
| 19 | }) |
| 20 | } |
| 21 | } |