-
Notifications
You must be signed in to change notification settings - Fork 0
/
response.go
21 lines (17 loc) · 921 Bytes
/
response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package utils
import (
"github.com/gin-gonic/gin"
"github.com/lbrulet/APINIT-GO/src/models"
)
// SendResponse is used to respond to the client
func SendResponse(c *gin.Context, code int, response *models.ResponsePayload) {
c.JSON(code, gin.H{"success": response.Success, "message": response.Message})
}
// SendLoginResponse is used to respond to the client
func SendLoginResponse(c *gin.Context, code int, response *models.LoginResponsePayload) {
c.JSON(code, gin.H{"success": response.Success, "message": response.Message, "token": response.Token, "refresh-token": response.RefreshToken, "user": response.User})
}
// SendRegisterResponse is used to respond to the client
func SendRegisterResponse(c *gin.Context, code int, response *models.RegisterResponsePayload) {
c.JSON(code, gin.H{"success": response.Success, "message": response.Message, "confirm_account_token": response.Token, "user": response.User})
}