fiberfx

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const StatusClientClosedRequest = 499

StatusClientClosedRequest is the HTTP status code for client closed request errors.

Variables

This section is empty.

Functions

func Module

func Module() fx.Option

func New

func New(config Config, option Options, logger *zap.Logger) *fiber.App

func NewCustomJSONErrorHandler

func NewCustomJSONErrorHandler(logger *zap.Logger, formatter ErrorFormatter) fiber.ErrorHandler

NewCustomJSONErrorHandler returns a fiber.ErrorHandler that formats the given error and HTTP status code using the provided ErrorFormatter, and sends the result as a JSON response. If the formatter is nil, it falls back to using NewErrorResponse to format the error.

func NewJSONErrorHandler

func NewJSONErrorHandler(logger *zap.Logger) fiber.ErrorHandler

NewJSONErrorHandler returns a fiber.ErrorHandler that formats the given error and HTTP status code using the NewErrorResponse function, and sends the result as a JSON response.

func NewViewsErrorHandler

func NewViewsErrorHandler(logger *zap.Logger, template string, layouts ...string) fiber.ErrorHandler

NewViewsErrorHandler creates a fiber.ErrorHandler that renders the given template with the error message and status code. If rendering fails, it falls back to sending the error message as a plain-text response. The logger is used to log errors that occur while rendering the view. The layouts are passed to the Render method as is.

Types

type Config

type Config struct {
	Address     string
	ProxyHeader string
	Proxies     []string
}

type ErrorFormatter

type ErrorFormatter func(err error, code int) any

ErrorFormatter formats an error and HTTP status code into a JSON-serializable payload.

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
	Code    int    `json:"code,omitempty"`
	Details any    `json:"details,omitempty"`
}

func NewErrorResponse

func NewErrorResponse(message string, code int, details any) ErrorResponse

type Options

type Options struct {
	// contains filtered or unexported fields
}

func (*Options) WithErrorHandler

func (o *Options) WithErrorHandler(handler fiber.ErrorHandler) *Options

func (*Options) WithGetOnly

func (o *Options) WithGetOnly() *Options

func (*Options) WithMetrics added in v0.1.0

func (o *Options) WithMetrics() *Options

func (*Options) WithViews

func (o *Options) WithViews(views fiber.Views) *Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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