modelRT/handler/helper.go

33 lines
596 B
Go

// Package handler provides HTTP handlers for various endpoints.
package handler
import (
"net/http"
"modelRT/network"
"github.com/gin-gonic/gin"
)
func renderRespFailure(c *gin.Context, code int, msg string, payload any) {
resp := network.FailureResponse{
Code: code,
Msg: msg,
}
if payload != nil {
resp.Payload = payload
}
c.JSON(http.StatusOK, resp)
}
func renderRespSuccess(c *gin.Context, code int, msg string, payload any) {
resp := network.SuccessResponse{
Code: code,
Msg: msg,
}
if payload != nil {
resp.Payload = payload
}
c.JSON(http.StatusOK, resp)
}