(c *gin.Context)
| 33 | } |
| 34 | |
| 35 | func Register(c *gin.Context) { |
| 36 | username := c.Query("username") |
| 37 | password := c.Query("password") |
| 38 | |
| 39 | token := username + password |
| 40 | |
| 41 | if _, exist := usersLoginInfo[token]; exist { |
| 42 | c.JSON(http.StatusOK, UserLoginResponse{ |
| 43 | Response: Response{StatusCode: 1, StatusMsg: "User already exist"}, |
| 44 | }) |
| 45 | } else { |
| 46 | atomic.AddInt64(&userIdSequence, 1) |
| 47 | newUser := User{ |
| 48 | Id: userIdSequence, |
| 49 | Name: username, |
| 50 | } |
| 51 | usersLoginInfo[token] = newUser |
| 52 | c.JSON(http.StatusOK, UserLoginResponse{ |
| 53 | Response: Response{StatusCode: 0}, |
| 54 | UserId: userIdSequence, |
| 55 | Token: username + password, |
| 56 | }) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func Login(c *gin.Context) { |
| 61 | username := c.Query("username") |
nothing calls this directly
no outgoing calls
no test coverage detected