Documentation ¶
Index ¶
- Constants
- Variables
- func GetErrorCode(err error) int
- func GetErrorCodeStr(err error) string
- func GetHTTPCode(code string) int
- type JSONResponse
- func (r *JSONResponse) Send(w http.ResponseWriter)
- func (r *JSONResponse) SetData(data interface{}) *JSONResponse
- func (r *JSONResponse) SetError(err error, a ...string) *JSONResponse
- func (r *JSONResponse) SetLatency(latency float64) *JSONResponse
- func (r *JSONResponse) SetLog(key string, val interface{}) *JSONResponse
- func (r *JSONResponse) SetMessage(msg string) *JSONResponse
- func (r *JSONResponse) SetSuccess(code int) *JSONResponse
Constants ¶
View Source
const ( STATUSCODE_GENERICSUCCESS = "200000" STATUSCODE_BADREQUEST = "400000" STATUSCODE_NOLINKEREXIST = "411553" STATUSCODE_UNAUTHORIZED = "401000" STATUS_FORBIDDEN = "403000" STATUSCODE_NOT_FOUND = "404000" STATUSCODE_GENERIC_PRECONDITION_FAILED = "412000" // todo error code change from 412 to 400 dur to nginx issue STATUSCODE_INTERNAL_ERROR = "500000" STATUSCODE_TIMEOUT_ERROR = "504000" STATUSCODE_ALREADY_REGISTERED = "400001" STATUSCODE_TX_ALREADY_DONE = "400003" STATUSCODE_GENERIC_PRECONDITION_FAILED_TEST = "412000" STATUSCODE_REQUIRED_TOKEN = "401000" STATUS_DATA_EMPTY = "2000001" )
Variables ¶
View Source
var ( ErrBadRequest = errors.New("Bad request") ErrForbiddenResource = errors.New("Forbidden resource") ErrForbiddenNakama = errors.New("Terms and conditions not accepted") ErrNotFound = errors.New("Not Found") ErrPreConditionFailed = errors.New("Precondition failed") ErrInternalServerError = errors.New("Internal server error") ErrTimeoutError = errors.New("Timeout error") ErrAlreadyRegistered = errors.New("User already registered") ErrNoLinkerExists = errors.New("No Linker exist") ErrNoValidUserFound = errors.New("No Valid User Found") ErrTxnAlreadyDone = errors.New("Transaction Already Done") ErrExcessRefundAmount = errors.New("Excess Refund Amount") ErrRefundAlreadyDone = errors.New("Refund already done") ErrInvalidTxnId = errors.New("Invalid Transaction Id") ErrDuplicateReq = errors.New("Duplicate Request") ErrSignatureMisMatch = errors.New("Signature MisMatch") ErrRefundAgainstInvalidTxnType = errors.New("Refund not allowed against Txn with Non-Payment type") ErrSaldoRefundAlreadyProcessed = errors.New("Saldo Redund Already processed") ErrNoUnsettledBillFound = errors.New("No Unsettled Bill Found") ErrInvalidOTP = errors.New("Invalid OTP") ErrPreConditionFailedTest = errors.New("Precondition failed test") ErrTokopediaEmail = errors.New("Tokopedia email id can not be used") ErrNoBillFound = errors.New("No Bill found") ErrBillDueDatePassed = errors.New("Last date to pay bill is over, pay your bill in next billing cycle.") ErrNoOVOWallet = errors.New("OVO wallet not found") ErrInvalidToken = errors.New("Invalid auth token") ErrRequiredToken = errors.New("Auth token is required") )
Functions ¶
func GetErrorCode ¶
func GetErrorCodeStr ¶
func GetHTTPCode ¶
Types ¶
type JSONResponse ¶
type JSONResponse struct { Code string `json:"code"` Message string `json:"message,omitempty"` ErrorMessage []*err.ErrorFormat `json:"error_message,omitempty"` ErrorString string `json:"error,omitempty"` Data interface{} `json:"data,omitempty"` Latency string `json:"latency"` StatusCode int `json:"-"` Error error `json:"-"` Log map[string]interface{} `json:"-"` Ctx context.Context `json:"-"` Success *int `json:"success,omitempty"` }
func NewJSONResponse ¶
func NewJSONResponse() *JSONResponse
func NewJSONResponseWithCtx ¶
func NewJSONResponseWithCtx(ctx context.Context) *JSONResponse
func (*JSONResponse) Send ¶
func (r *JSONResponse) Send(w http.ResponseWriter)
func (*JSONResponse) SetData ¶
func (r *JSONResponse) SetData(data interface{}) *JSONResponse
func (*JSONResponse) SetError ¶
func (r *JSONResponse) SetError(err error, a ...string) *JSONResponse
func (*JSONResponse) SetLatency ¶
func (r *JSONResponse) SetLatency(latency float64) *JSONResponse
func (*JSONResponse) SetLog ¶
func (r *JSONResponse) SetLog(key string, val interface{}) *JSONResponse
func (*JSONResponse) SetMessage ¶
func (r *JSONResponse) SetMessage(msg string) *JSONResponse
func (*JSONResponse) SetSuccess ¶
func (r *JSONResponse) SetSuccess(code int) *JSONResponse
Click to show internal directories.
Click to hide internal directories.