utils

package
v0.0.0-...-bd5dacb Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusBadRequest                   = 400
	StatusUnauthorized                 = 401
	StatusPaymentRequired              = 402
	StatusForbidden                    = 403
	StatusNotFound                     = 404
	StatusMethodNotAllowed             = 405
	StatusNotAcceptable                = 406
	StatusProxyAuthRequired            = 407
	StatusRequestTimeout               = 408
	StatusConflict                     = 409
	StatusGone                         = 410
	StatusLengthRequired               = 411
	StatusPreconditionFailed           = 412
	StatusRequestEntityTooLarge        = 413
	StatusRequestURITooLong            = 414
	StatusUnsupportedMediaType         = 415
	StatusRequestedRangeNotSatisfiable = 416
	StatusExpectationFailed            = 417
	StatusTeapot                       = 418
	StatusMisdirectedRequest           = 421
	StatusUnprocessableEntity          = 422
	StatusLocked                       = 423
	StatusFailedDependency             = 424
	StatusTooEarly                     = 425
	StatusUpgradeRequired              = 426
	StatusPreconditionRequired         = 428
	StatusTooManyRequests              = 429
	StatusRequestHeaderFieldsTooLarge  = 431
	StatusUnavailableForLegalReasons   = 451

	StatusInternalServerError           = 500
	StatusNotImplemented                = 501
	StatusBadGateway                    = 502
	StatusServiceUnavailable            = 503
	StatusGatewayTimeout                = 504
	StatusHTTPVersionNotSupported       = 505
	StatusVariantAlsoNegotiates         = 506
	StatusInsufficientStorage           = 507
	StatusLoopDetected                  = 508
	StatusNotExtended                   = 510
	StatusNetworkAuthenticationRequired = 511
)

Error status codes

Variables

This section is empty.

Functions

func GetKeyFromAlgo

func GetKeyFromAlgo(algo, secret, keyPath string) (interface{}, error)

GetKeyFromAlgo returns a key from an algorithm and a secret

func GetTokenAndKeyFromAlgo

func GetTokenAndKeyFromAlgo(algo, secret, keyPath string) (*jwt.Token, interface{}, error)

GetTokenAndKeyFromAlgo returns a token and a key from an algorithm and a secret

func LoadECDSAKeyFromFile

func LoadECDSAKeyFromFile(filename string, isPrivate bool) (any, error)

LoadECDSAKeyFromFile loads an ECDSA private or public key from a file

func NewError

func NewError(c *fiber.Ctx, logger *zap.Logger, msg, details string, err error) *fiber.Error

NewError returns a fiber error and log the error.

Types

type HTTPError

type HTTPError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Details interface{} `json:"details,omitempty"`
	Err     error       `json:"-"`
}

HTTPError represents an HTTP error.

func NewHTTPError

func NewHTTPError(code int, message string, details interface{}, err error) *HTTPError

NewHTTPError returns a new HTTPError.

func (HTTPError) Error

func (e HTTPError) Error() string

type ValidatorError

type ValidatorError struct {
	FailedField string
	Tag         string
	Value       string
}

ValidatorError represents error validation struct.

func (ValidatorError) Error

func (ve ValidatorError) Error() string

TODO: Change

type ValidatorErrors

type ValidatorErrors []ValidatorError

ValidatorErrors is a slice of ValidatorError.

func ValidateStruct

func ValidateStruct(task interface{}) (errors ValidatorErrors)

ValidateStruct checks if a struct is valid and returns an array of errors if it is not valid.

func (ValidatorErrors) Error

func (ve ValidatorErrors) Error() string

TODO: Change

Jump to

Keyboard shortcuts

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