Documentation ¶
Index ¶
- Constants
- func ErrorMessage(code string) string
- func WriteApiJsonResponse(w http.ResponseWriter, result interface{}, statusCode int, errCode string, ...)
- func WriteApiJsonResponseStructured(w http.ResponseWriter, apiResponse *ApiResponse, statusCode int)
- func WriteJsonResp(w http.ResponseWriter, err error, respBody interface{}, status int)
- type ApiResponse
- type ErrorResponse
- type Response
Constants ¶
View Source
const ( UnAuthenticated = "E100" UnAuthorized = "E101" BadRequest = "E102" InternalServerError = "E103" ResourceNotFound = "E104" UnknownError = "E105" )
Variables ¶
This section is empty.
Functions ¶
func ErrorMessage ¶
func WriteApiJsonResponse ¶
func WriteApiJsonResponse(w http.ResponseWriter, result interface{}, statusCode int, errCode string, errorMessage string)
func WriteApiJsonResponseStructured ¶
func WriteApiJsonResponseStructured(w http.ResponseWriter, apiResponse *ApiResponse, statusCode int)
func WriteJsonResp ¶
func WriteJsonResp(w http.ResponseWriter, err error, respBody interface{}, status int)
use of writeJsonRespStructured is preferable. it api exists due to historical reason err.message is used as internal message for ApiError object in resp
Types ¶
type ApiResponse ¶
type ApiResponse struct { Success bool `json:"success,notnull" validate:"required"` Error *ErrorResponse `json:"error,omitempty"` Result interface{} `json:"result,omitempty"` }
type ErrorResponse ¶
Click to show internal directories.
Click to hide internal directories.