package dto import ( "github.com/gin-gonic/gin" "log" "net/http" "runtime/debug" ) func BadRequest(c *gin.Context, err error) { log.Printf("err: %+v", err) debug.PrintStack() c.JSON(http.StatusBadRequest, Response{ Status: 0, Message: err.Error(), }) } func Error(c *gin.Context, err error) { log.Printf("err: %+v", err) debug.PrintStack() c.JSON(http.StatusInternalServerError, Response{ Status: 0, Message: err.Error(), }) } func NewOkResponse() Response { return Response{Status: 1, Message: "ok"} } type Response struct { Status int `json:"status"` Message string `json:"message"` } type RegisterResponse struct { Response Data RegisterResult `json:"data"` } type RegisterResult struct { Success bool `json:"success"` } type ListResponse struct { Response Data []*Node `json:"data"` } type DetailResponse struct { Response Data Node `json:"data"` } type Node struct { CountryCode string `json:"countryCode"` CountryName string `json:"countryName"` City string `json:"city"` CountryLabel string `json:"countryLabel"` Ip string `json:"ip"` Icon string `json:"icon"` SecretUrl string `json:"secretUrl"` Continent string `json:"continent"` Vip bool `json:"vip"` } type GroupResponse struct { Response Data []*Group `json:"data"` } type Group struct { Continent string `json:"continent"` Nodes []*Node `json:"nodes"` } type ConfigResponse struct { Response Data ConfigResult `json:"data"` } type ConfigResult struct { FreeTrialDuration uint64 `json:"freeTrialDuration"` Timestamp int64 `json:"timestamp"` Node *Node `json:"node"` }