login.go 375 B

1234567891011121314151617181920
  1. package Controllers
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "goLoad1/Config"
  5. "net/http"
  6. )
  7. type loginInfo struct {
  8. }
  9. func (con loginInfo) loginController(c *gin.Context) {
  10. userID := 1
  11. token, err := Config.CreateToken(userID)
  12. if err != nil {
  13. c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
  14. return
  15. }
  16. c.JSON(http.StatusOK, gin.H{"token": token})
  17. }