Documentation
¶
Index ¶
- func Fail(w http.ResponseWriter, r *Exception, abort ...bool)
- func Success(w http.ResponseWriter, data ...any)
- func WithStatusCode(w http.ResponseWriter, statusCode int, data ...any)
- type Exception
- func AlreadyExists(message string, data ...any) *Exception
- func BadRequest(message string, data ...any) *Exception
- func Conflict(message string, data ...any) *Exception
- func DBQuery(message string, data ...any) *Exception
- func Forbidden(message string, data ...any) *Exception
- func Gone(message string, data ...any) *Exception
- func InternalServer(message string, data ...any) *Exception
- func NotAllowed(message string, data ...any) *Exception
- func NotExists(message string, data ...any) *Exception
- func NotFound(message string, data ...any) *Exception
- func ServiceUnavailable(message string, data ...any) *Exception
- func Transactions(message string, data ...any) *Exception
- func UnAuthorized(message string, data ...any) *Exception
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fail ¶
func Fail(w http.ResponseWriter, r *Exception, abort ...bool)
Fail handles failure responses.
func WithStatusCode ¶ added in v0.1.5
func WithStatusCode(w http.ResponseWriter, statusCode int, data ...any)
WithStatusCode handles success responses with custom status code.
Types ¶
type Exception ¶
type Exception struct {
Status int `json:"status,omitempty"` // HTTP status
Code int `json:"code,omitempty"` // Business code
Message string `json:"message,omitempty"` // Message
Errors any `json:"errors,omitempty"` // Validation errors
Data any `json:"data,omitempty"` // Response data
}
Exception represents the response structure.
func AlreadyExists ¶
AlreadyExists indicates that the resource already exists.
func BadRequest ¶
BadRequest indicates a bad request.
func InternalServer ¶
InternalServer indicates a server error.
func NotAllowed ¶
NotAllowed indicates a not allowed error.
func ServiceUnavailable ¶ added in v0.1.4
ServiceUnavailable indicates a service is unavailable.
func Transactions ¶
Transactions indicates a transaction processing failure.
func UnAuthorized ¶
UnAuthorized indicates that the request is unauthorized.
Click to show internal directories.
Click to hide internal directories.