controller_base.go 609 B

1234567891011121314151617181920212223242526
  1. package v1
  2. import (
  3. "github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
  4. "github.com/allanpk716/ChineseSubFinder/internal/types/backend"
  5. "github.com/gin-gonic/gin"
  6. "net/http"
  7. )
  8. type ControllerBase struct {
  9. }
  10. func NewControllerBase() *ControllerBase {
  11. return &ControllerBase{}
  12. }
  13. func (cb ControllerBase) GetVersion() string {
  14. return "v1"
  15. }
  16. func (cb *ControllerBase) ErrorProcess(c *gin.Context, funcName string, err error) {
  17. if err != nil {
  18. log_helper.GetLogger().Errorln(funcName, err.Error())
  19. c.JSON(http.StatusInternalServerError, backend.ReplyCommon{Message: err.Error()})
  20. }
  21. }