Documentation ¶
Index ¶
- Variables
- func IsJsonErrorGetDetails(err error) (ok bool, e error)
- func JSON(w http.ResponseWriter, vPtr *Response, headers map[string]string)
- type Response
- func BadRequest(msg string, errorCode string) *Response
- func Conflict(msg string, errorCode string) *Response
- func Created(msg string, data any) *Response
- func Forbidden(msg string, errorCode string) *Response
- func InternalServerError(msg string, errorCode string) *Response
- func New(statusCode int, success bool, msg string, errorCode *string, data any) *Response
- func NewError(statusCode int, msg string, errorCode string) *Response
- func NewSuccess(statusCode int, msg string, data any) *Response
- func NotFound(msg string, errorCode string) *Response
- func Ok(msg string, data any) *Response
- func Unauthorized(msg string, errorCode string) *Response
Constants ¶
This section is empty.
Variables ¶
View Source
var UseDefaultCode = true
Functions ¶
func IsJsonErrorGetDetails ¶
IsJsonErrorGetDetails takes an error and check if it is a JSON Error. If it is, it returns true and the type of json Error Else it returns the error back as it came
Types ¶
type Response ¶
type Response struct { StatusCode int `json:"-"` Success bool `json:"success"` Message string `json:"message"` ErrorCode *string `json:"errorCode,omitempty"` Data any `json:"data,omitempty"` }
Response this struct represents the response structure.
func BadRequest ¶
BadRequest creates a error response with (HTTP 400) code
func InternalServerError ¶
InternalServerError creates a error response with (HTTP 500)code
func NewSuccess ¶
NewSuccess creates a success response
func Unauthorized ¶
Unauthorized creates a error response with (HTTP 401) code
func (Response) Error ¶
Error, lets satisfy golang's error interface. so we can return 'response' as an error type.
func (*Response) OverideDefaultMsg ¶
OverideDefaultMsg helps overide or set a message useful in shorthand variables dfinition
Click to show internal directories.
Click to hide internal directories.