-
improve error handeling with "errors.Is"
if result.Error != nil { if !errors.Is(result.Error, gorm.ErrRecordNotFound) { return a, errors.New(errors.SERVER_ERROR, proper.error.message) } }
-
add Localization module
-
add custom error handeling in application.go like this sample:
func NewHTTPError(err error) *HttpError { if custom, ok := err.(*CustomError); ok { code, ok := HttpProtoStatus[custom.Status] if !ok { code = HttpProtoStatus[SERVER_ERROR] } return &HttpError{ Message: custom.Message, Status: custom.Errors, StatusCode: code, } } return &HttpError{ Message: lang.Use.Error.App.InternalError, Status: ProtocolMessage[SERVER_ERROR], StatusCode: HttpProtoStatus[SERVER_ERROR], } }
-
remove useless pointers from methods
-
add rate limiter middleware with redis
-
use better redis keys
-
use enum in role constants