Documentation
¶
Index ¶
- func SendPaginatedResponse(c *fiber.Ctx, response PaginatedResponse) error
- func SendResponse(c *fiber.Ctx, response Response) error
- func SendValidationResponse(c *fiber.Ctx, response ValidationResponse) error
- type PaginatedResponse
- type Pagination
- type Response
- func Accepted(message string, data interface{}) Response
- func BadGateway(message string) Response
- func BadRequest(message string, err error) Response
- func Conflict(message string, err error) Response
- func Created(message string, data interface{}) Response
- func CustomStatus(message string, err error, status int) Response
- func ExpectationFailed(message string) Response
- func FailedDependency(message string) Response
- func Forbidden(message string) Response
- func GatewayTimeout(message string) Response
- func Gone(message string) Response
- func HTTPVersionNotSupported(message string) Response
- func InsufficientStorage(message string) Response
- func InternalServerError(message string, err error) Response
- func LengthRequired(message string) Response
- func Locked(message string) Response
- func LoopDetected(message string) Response
- func MethodNotAllowed(message string) Response
- func NetworkAuthenticationRequired(message string) Response
- func NoContent(message string) Response
- func NotAcceptable(message string) Response
- func NotExtended(message string) Response
- func NotFound(message string) Response
- func NotImplemented(message string) Response
- func NotModified(message string) Response
- func OK(message string, data interface{}) Response
- func PartialContent(message string, data interface{}) Response
- func PayloadTooLarge(message string) Response
- func PaymentRequired(message string) Response
- func PreconditionFailed(message string) Response
- func PreconditionRequired(message string) Response
- func ProxyAuthenticationRequired(message string) Response
- func RangeNotSatisfiable(message string) Response
- func RequestHeaderFieldsTooLarge(message string) Response
- func RequestTimeout(message string) Response
- func ServiceUnavailable(message string) Response
- func Teapot(message string) Response
- func TooEarly(message string) Response
- func TooManyRequests(message string) Response
- func URITooLong(message string) Response
- func Unauthorized(message string) Response
- func UnavailableForLegalReasons(message string) Response
- func UnprocessableEntity(message string, err error) Response
- func UnsupportedMediaType(message string) Response
- func UpgradeRequired(message string) Response
- func VariantAlsoNegotiates(message string) Response
- type ValidationError
- type ValidationResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendPaginatedResponse ¶
func SendPaginatedResponse(c *fiber.Ctx, response PaginatedResponse) error
SendPaginatedResponse sends a paginated response using Fiber context
func SendResponse ¶
SendResponse sends a response using Fiber context
func SendValidationResponse ¶
func SendValidationResponse(c *fiber.Ctx, response ValidationResponse) error
SendValidationResponse sends a validation error response using Fiber context
Types ¶
type PaginatedResponse ¶
type PaginatedResponse struct {
Response
Pagination *Pagination `json:"pagination,omitempty"`
}
PaginatedResponse represents a paginated API response
func Paginated ¶
func Paginated(message string, data interface{}, pagination *Pagination) PaginatedResponse
Paginated creates a paginated success response
type Pagination ¶
type Pagination struct {
Page int `json:"page"`
PerPage int `json:"per_page"`
Total int64 `json:"total"`
TotalPages int `json:"total_pages"`
HasNext bool `json:"has_next"`
HasPrevious bool `json:"has_previous"`
NextPage *int `json:"next_page,omitempty"`
PreviousPage *int `json:"previous_page,omitempty"`
}
Pagination contains pagination metadata
func NewPagination ¶
func NewPagination(page, perPage int, total int64) *Pagination
NewPagination creates pagination metadata
type Response ¶
type Response struct {
Success bool `json:"success"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Status int `json:"status"`
Timestamp time.Time `json:"timestamp"`
}
Response represents a standard API response
func BadGateway ¶
BadGateway creates a 502 Bad Gateway response
func BadRequest ¶
BadRequest creates a 400 Bad Request response
func CustomStatus ¶
CustomStatus creates a response with custom status code
func ExpectationFailed ¶
ExpectationFailed creates a 417 Expectation Failed response
func FailedDependency ¶
FailedDependency creates a 424 Failed Dependency response
func GatewayTimeout ¶
GatewayTimeout creates a 504 Gateway Timeout response
func HTTPVersionNotSupported ¶
HTTPVersionNotSupported creates a 505 HTTP Version Not Supported response
func InsufficientStorage ¶
InsufficientStorage creates a 507 Insufficient Storage response
func InternalServerError ¶
InternalServerError creates a 500 Internal Server Error response
func LengthRequired ¶
LengthRequired creates a 411 Length Required response
func LoopDetected ¶
LoopDetected creates a 508 Loop Detected response
func MethodNotAllowed ¶
MethodNotAllowed creates a 405 Method Not Allowed response
func NetworkAuthenticationRequired ¶
NetworkAuthenticationRequired creates a 511 Network Authentication Required response
func NotAcceptable ¶
NotAcceptable creates a 406 Not Acceptable response
func NotExtended ¶
NotExtended creates a 510 Not Extended response
func NotImplemented ¶
NotImplemented creates a 501 Not Implemented response
func NotModified ¶
NotModified creates a 304 Not Modified response
func PartialContent ¶
PartialContent creates a 206 Partial Content response
func PayloadTooLarge ¶
PayloadTooLarge creates a 413 Payload Too Large response
func PaymentRequired ¶
PaymentRequired creates a 402 Payment Required response
func PreconditionFailed ¶
PreconditionFailed creates a 412 Precondition Failed response
func PreconditionRequired ¶
PreconditionRequired creates a 428 Precondition Required response
func ProxyAuthenticationRequired ¶
ProxyAuthenticationRequired creates a 407 Proxy Authentication Required response
func RangeNotSatisfiable ¶
RangeNotSatisfiable creates a 416 Range Not Satisfiable response
func RequestHeaderFieldsTooLarge ¶
RequestHeaderFieldsTooLarge creates a 431 Request Header Fields Too Large response
func RequestTimeout ¶
RequestTimeout creates a 408 Request Timeout response
func ServiceUnavailable ¶
ServiceUnavailable creates a 503 Service Unavailable response
func TooManyRequests ¶
TooManyRequests creates a 429 Too Many Requests response
func URITooLong ¶
URITooLong creates a 414 URI Too Long response
func Unauthorized ¶
Unauthorized creates a 401 Unauthorized response
func UnavailableForLegalReasons ¶
UnavailableForLegalReasons creates a 451 Unavailable For Legal Reasons response
func UnprocessableEntity ¶
UnprocessableEntity creates a 422 Unprocessable Entity response
func UnsupportedMediaType ¶
UnsupportedMediaType creates a 415 Unsupported Media Type response
func UpgradeRequired ¶
UpgradeRequired creates a 426 Upgrade Required response
func VariantAlsoNegotiates ¶
VariantAlsoNegotiates creates a 506 Variant Also Negotiates response
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Message string `json:"message"`
Value string `json:"value,omitempty"`
}
ValidationError represents a field validation error
type ValidationResponse ¶
type ValidationResponse struct {
Response
Errors []ValidationError `json:"validation_errors,omitempty"`
}
ValidationResponse represents a validation error response
func UnprocessableEntityWithValidation ¶
func UnprocessableEntityWithValidation(message string, errors []ValidationError) ValidationResponse
UnprocessableEntityWithValidation creates a 422 Unprocessable Entity response with validation errors