Documentation
¶
Index ¶
- Variables
- func TranslateErrorToStatusCode(err error) int
- type BaseHttpResponse
- func GenerateBaseResponse(result any, success bool, resultCode ResultCode) *BaseHttpResponse
- func GenerateBaseResponseWithAnyError(result any, success bool, resultCode ResultCode, err any) *BaseHttpResponse
- func GenerateBaseResponseWithError(result any, success bool, resultCode ResultCode, err error) *BaseHttpResponse
- func GenerateBaseResponseWithValidationError(result any, success bool, resultCode ResultCode, err error) *BaseHttpResponse
- type ResultCode
Constants ¶
This section is empty.
Variables ¶
View Source
var StatusCodeMapping = map[string]int{ service_errors.OptExists: 409, service_errors.OtpUsed: 409, service_errors.OtpNotValid: 400, service_errors.EmailExists: 409, service_errors.UsernameExists: 409, service_errors.RecordNotFound: 404, service_errors.PermissionDenied: 403, }
Functions ¶
Types ¶
type BaseHttpResponse ¶
type BaseHttpResponse struct { Result any `json:"result"` Success bool `json:"success"` ResultCode ResultCode `json:"resultCode"` ValidationErrors *[]validation.ValidationError `json:"validationErrors"` Error any `json:"error"` }
func GenerateBaseResponse ¶
func GenerateBaseResponse(result any, success bool, resultCode ResultCode) *BaseHttpResponse
func GenerateBaseResponseWithAnyError ¶
func GenerateBaseResponseWithAnyError(result any, success bool, resultCode ResultCode, err any) *BaseHttpResponse
func GenerateBaseResponseWithError ¶
func GenerateBaseResponseWithError(result any, success bool, resultCode ResultCode, err error) *BaseHttpResponse
func GenerateBaseResponseWithValidationError ¶
func GenerateBaseResponseWithValidationError(result any, success bool, resultCode ResultCode, err error) *BaseHttpResponse
type ResultCode ¶
type ResultCode int
const ( Success ResultCode = 0 ValidationError ResultCode = 40001 AuthError ResultCode = 40101 ForbiddenError ResultCode = 40301 NotFoundError ResultCode = 40401 LimiterError ResultCode = 42901 OtpLimiterError ResultCode = 42902 CustomRecovery ResultCode = 50001 InternalError ResultCode = 50002 )
Click to show internal directories.
Click to hide internal directories.