http

package
v3.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accepted

func Accepted(c *fiber.Ctx, s any) error

Accepted sends an HTTP 202 Accepted response with a custom body.

func BadRequest

func BadRequest(c *fiber.Ctx, s any) error

BadRequest sends an HTTP 400 Bad Request response with a custom body.

func Conflict

func Conflict(c *fiber.Ctx, code, title, message string) error

Conflict sends an HTTP 409 Conflict response with a custom code, title and message.

func Created

func Created(c *fiber.Ctx, s any) error

Created sends an HTTP 201 Created response with a custom body.

func FindUnknownFields

func FindUnknownFields(original, marshaled map[string]any) map[string]any

FindUnknownFields finds fields that are present in the original map but not in the marshaled map.

func Forbidden

func Forbidden(c *fiber.Ctx, code, title, message string) error

Forbidden sends an HTTP 403 Forbidden response with a custom code, title and message.

func GetBooleanParam added in v3.5.0

func GetBooleanParam(c *fiber.Ctx, queryParamName string) bool

func GetFileFromHeader

func GetFileFromHeader(ctx *fiber.Ctx) (string, error)

GetFileFromHeader method that get file from header and give a string fom this dsl gold file

func GetIdempotencyKeyAndTTL

func GetIdempotencyKeyAndTTL(c *fiber.Ctx) (string, time.Duration)

GetIdempotencyKeyAndTTL returns idempotency key and ttl if pass through.

func GetPayloadFromContext

func GetPayloadFromContext(c *fiber.Ctx) any

GetPayloadFromContext retrieves the decoded request payload from the Fiber context.

func GetUUIDFromLocals added in v3.5.0

func GetUUIDFromLocals(c *fiber.Ctx, key string) (uuid.UUID, error)

GetUUIDFromLocals safely extracts a UUID from fiber context locals. Returns an error if the value is nil or not a valid UUID.

func InternalServerError

func InternalServerError(c *fiber.Ctx, code, title, message string) error

InternalServerError sends an HTTP 500 Internal Server Error response

func JSONResponse

func JSONResponse(c *fiber.Ctx, status int, s any) error

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 NoContent

func NoContent(c *fiber.Ctx) error

NoContent sends an HTTP 204 No Content response without anybody.

func NotFound

func NotFound(c *fiber.Ctx, code, title, message string) error

NotFound sends an HTTP 404 Not Found response with a custom code, title and message.

func NotImplemented

func NotImplemented(c *fiber.Ctx, message string) error

NotImplemented sends an HTTP 501 Not Implemented response with a custom message.

func OK

func OK(c *fiber.Ctx, s any) error

OK sends an HTTP 200 OK response with a custom body.

func ParseUUIDPathParameters

func ParseUUIDPathParameters(entityName string) fiber.Handler

ParseUUIDPathParameters globally, considering all path parameters are UUIDs and adding them to the span attributes entityName is a snake_case string used to identify id name, for example the "organization" entity name will result in "app.request.organization_id" otherwise the path parameter "id" in a request for example "/v1/organizations/:id" will be parsed as "app.request.id"

func PartialContent

func PartialContent(c *fiber.Ctx, s any) error

PartialContent sends an HTTP 206 Partial Content response with a custom body.

func RangeNotSatisfiable

func RangeNotSatisfiable(c *fiber.Ctx) error

RangeNotSatisfiable sends an HTTP 416 Requested Range Not Satisfiable response.

func ServiceUnavailable added in v3.4.8

func ServiceUnavailable(c *fiber.Ctx, code, title, message string) error

ServiceUnavailable sends an HTTP 503 Service Unavailable response with a custom code, title and message.

func Unauthorized

func Unauthorized(c *fiber.Ctx, code, title, message string) error

Unauthorized sends an HTTP 401 Unauthorized response with a custom code, title and message.

func UnprocessableEntity

func UnprocessableEntity(c *fiber.Ctx, code, title, message string) error

UnprocessableEntity sends an HTTP 422 Unprocessable Entity response with a custom code, title and message.

func ValidateMetadataValue added in v3.5.0

func ValidateMetadataValue(value any) (any, error)

ValidateMetadataValue validates a metadata value, ensuring it meets specific criteria for type and length. It supports strings, numbers, booleans, nil, and arrays without nested maps or overly long strings.

func ValidateStruct

func ValidateStruct(s any) error

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

WithDecode wraps a handler function, providing it with a struct instance created using the provided constructor function.

func WithError

func WithError(c *fiber.Ctx, err error) error

WithError returns an error with the given status code and message.

func WithRecover added in v3.5.0

func WithRecover(opts ...RecoverMiddlewareOption) fiber.Handler

Types

type ConstructorFunc

type ConstructorFunc func() any

ConstructorFunc representing a constructor of any type.

type DecodeHandlerFunc

type DecodeHandlerFunc func(p any, c *fiber.Ctx) error

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

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
	OperationType                       string
	ToAssetCodes                        []string
	HolderID                            *string
	ExternalID                          *string
	Document                            *string
	AccountID                           *string
	LedgerID                            *string
	BankingDetailsBranch                *string
	BankingDetailsAccount               *string
	BankingDetailsIban                  *string
	EntityName                          *string
	RegulatoryFieldsParticipantDocument *string
	RelatedPartyDocument                *string
	RelatedPartyRole                    *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

func (qh *QueryHeader) ToCursorPagination() Pagination

func (*QueryHeader) ToOffsetPagination

func (qh *QueryHeader) ToOffsetPagination() Pagination

type RecoverMiddlewareOption added in v3.5.0

type RecoverMiddlewareOption func(r *recoverMiddleware)

func WithRecoverLogger added in v3.5.0

func WithRecoverLogger(logger libLog.Logger) RecoverMiddlewareOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL