Documentation
¶
Index ¶
- func Accepted(c *fiber.Ctx, s any) error
- func BadRequest(c *fiber.Ctx, s any) error
- func Conflict(c *fiber.Ctx, code, title, message string) error
- func Created(c *fiber.Ctx, s any) error
- func Forbidden(c *fiber.Ctx, code, title, message string) error
- func GetFileFromHeader(ctx *fiber.Ctx) (string, error)
- func GetIdempotencyKeyAndTTL(c *fiber.Ctx) (string, time.Duration)
- func GetPayloadFromContext(c *fiber.Ctx) any
- func InternalServerError(c *fiber.Ctx, code, title, message string) error
- func JSONResponse(c *fiber.Ctx, status int, s any) error
- func JSONResponseError(c *fiber.Ctx, err pkg.ResponseError) error
- func NoContent(c *fiber.Ctx) error
- func NotFound(c *fiber.Ctx, code, title, message string) error
- func NotImplemented(c *fiber.Ctx, message string) error
- func OK(c *fiber.Ctx, s any) error
- func ParseUUIDPathParameters(c *fiber.Ctx) error
- func PartialContent(c *fiber.Ctx, s any) error
- func RangeNotSatisfiable(c *fiber.Ctx) error
- func Unauthorized(c *fiber.Ctx, code, title, message string) error
- func UnprocessableEntity(c *fiber.Ctx, code, title, message string) error
- func ValidateStruct(s any) error
- func WithBody(s any, h DecodeHandlerFunc) fiber.Handler
- func WithDecode(c ConstructorFunc, h DecodeHandlerFunc) fiber.Handler
- func WithError(c *fiber.Ctx, err error) error
- type ConstructorFunc
- type DecodeHandlerFunc
- type Pagination
- type PayloadContextValue
- type QueryHeader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
BadRequest sends an HTTP 400 Bad Request response with a custom body.
func Forbidden ¶
Forbidden sends an HTTP 403 Forbidden response with a custom code, title and message.
func GetFileFromHeader ¶
GetFileFromHeader method that get file from header and give a string fom this dsl gold file
func GetIdempotencyKeyAndTTL ¶ added in v1.34.0
GetIdempotencyKeyAndTTL returns idempotency key and ttl if pass through.
func GetPayloadFromContext ¶
GetPayloadFromContext retrieves the decoded request payload from the Fiber context.
func InternalServerError ¶
InternalServerError sends an HTTP 500 Internal Server Error response
func JSONResponse ¶
JSONResponse sends a custom status code and body as a JSON response.
func JSONResponseError ¶
func JSONResponseError(c *fiber.Ctx, err pkg.ResponseError) error
JSONResponseError sends a JSON formatted error response with a custom error struct.
func NotFound ¶
NotFound sends an HTTP 404 Not Found response with a custom code, title and message.
func NotImplemented ¶
NotImplemented sends an HTTP 501 Not Implemented response with a custom message.
func ParseUUIDPathParameters ¶
ParseUUIDPathParameters globally, considering all path parameters are UUIDs
func PartialContent ¶
PartialContent sends an HTTP 206 Partial Content response with a custom body.
func RangeNotSatisfiable ¶
RangeNotSatisfiable sends an HTTP 416 Requested Range Not Satisfiable response.
func Unauthorized ¶
Unauthorized sends an HTTP 401 Unauthorized response with a custom code, title and message.
func UnprocessableEntity ¶
UnprocessableEntity sends an HTTP 422 Unprocessable Entity response with a custom code, title and message.
func ValidateStruct ¶
ValidateStruct validates a struct against defined validation rules, using the validator package.
func WithBody ¶
func WithBody(s any, h DecodeHandlerFunc) fiber.Handler
WithBody wraps a handler function, providing it with an instance of the specified struct.
func WithDecode ¶
func WithDecode(c ConstructorFunc, h DecodeHandlerFunc) fiber.Handler
WithDecode wraps a handler function, providing it with a struct instance created using the provided constructor function.
Types ¶
type ConstructorFunc ¶
type ConstructorFunc func() any
ConstructorFunc representing a constructor of any type.
type DecodeHandlerFunc ¶
DecodeHandlerFunc is a handler which works with withBody decorator. It receives a struct which was decoded by withBody decorator before. Ex: json -> withBody -> DecodeHandlerFunc.
func SetBodyInContext ¶
func SetBodyInContext(handler fiber.Handler) DecodeHandlerFunc
SetBodyInContext is a higher-order function that wraps a Fiber handler, injecting the decoded body into the request context.
type Pagination ¶ added in v1.31.0
type Pagination struct {
Limit int
Page int
Cursor string
SortOrder string
StartDate time.Time
EndDate time.Time
}
Pagination entity from query parameter from get apis
type PayloadContextValue ¶
type PayloadContextValue string
PayloadContextValue is a wrapper type used to keep Context.Locals safe.
type QueryHeader ¶
type QueryHeader struct {
Metadata *bson.M
Limit int
Page int
Cursor string
SortOrder string
StartDate time.Time
EndDate time.Time
UseMetadata bool
PortfolioID string
ToAssetCodes []string
}
QueryHeader entity from query parameter from get apis
func ValidateParameters ¶
func ValidateParameters(params map[string]string) (*QueryHeader, error)
ValidateParameters validate and return struct of default parameters
func (*QueryHeader) ToCursorPagination ¶ added in v1.31.0
func (qh *QueryHeader) ToCursorPagination() Pagination
func (*QueryHeader) ToOffsetPagination ¶ added in v1.31.0
func (qh *QueryHeader) ToOffsetPagination() Pagination