package ginutil import ( "kpt-tmr-group/pkg/apierr" "kpt-tmr-group/pkg/jsonpb" "net/http" "github.com/gin-gonic/gin" "github.com/golang/protobuf/proto" ) func JSONResp(c *gin.Context, pb proto.Message) { bs, err := jsonpb.MarshalBytes(pb) if err != nil { apierr.AbortInternalError(c, http.StatusInternalServerError, err) return } c.Data(http.StatusOK, "application/json", bs) }