common

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymmetricKeyLen = 32

	EventTypeCreate = "create"
	EventTypeUpdate = "update"
	EventTypeDelete = "delete"
)

Variables

View Source
var (
	ErrAuthentication  = errors.New("token authentication failed")
	ErrInvalidDateTime = errors.New("invalid date time format (RFC 3339 needed)")
	ErrKeyLen          = errors.New("PASETO_KEY must be 32 bytes long once base64-decoded")

	ErrDBUniqueConstraint = errors.New("db constraint violation")
	ErrDBRecordNotFound   = errors.New("record not found")
)

Functions

func CustomErrorHandler

func CustomErrorHandler(ctx *fiber.Ctx, err error) error

func NormalizeEmail added in v0.5.1

func NormalizeEmail(email string) string

func ValidateRequestEntity added in v0.5.1

func ValidateRequestEntity(ctx *fiber.Ctx, request interface{}, errorMessage string) error

Types

type Base64Key

type Base64Key [SymmetricKeyLen]byte

func (*Base64Key) UnmarshalText

func (k *Base64Key) UnmarshalText(text []byte) error

type CodeHosting

type CodeHosting struct {
	URL   string `json:"url" validate:"required,url"`
	Group *bool  `json:"group"`
}

type Environment

type Environment struct {
	MaxRequests        int        `env:"MAX_REQUESTS" envDefault:"0"`
	CurrentEnvironment string     `env:"ENVIRONMENT" envDefault:"production"`
	Database           string     `env:"DATABASE_DSN"`
	PasetoKey          *Base64Key `env:"PASETO_KEY"`
}
var EnvironmentConfig Environment //nolint:gochecknoglobals

func (*Environment) IsTest

func (e *Environment) IsTest() bool

type Log

type Log struct {
	Message string `json:"message" validate:"required,gt=1"`
}

type ProblemJSONError

type ProblemJSONError struct {
	Code             string            `json:"code,omitempty"`
	Title            string            `json:"title"`
	Detail           string            `json:"detail,omitempty"`
	Status           int               `json:"status"`
	ValidationErrors []ValidationError `json:"validationErrors,omitempty"`
}

func Error

func Error(status int, title string, detail string) ProblemJSONError

func ErrorWithValidationErrors

func ErrorWithValidationErrors(
	status int, title string, detail string, validationErrors []ValidationError,
) ProblemJSONError

func (ProblemJSONError) Error

func (pj ProblemJSONError) Error() string

type PublisherPatch added in v0.5.1

type PublisherPatch struct {
	CodeHosting  []CodeHosting `json:"codeHosting" validate:"gt=0"`
	Description  string        `json:"description"`
	Email        string        `json:"email" validate:"email"`
	Active       *bool         `json:"active"`
	ExternalCode string        `json:"externalCode" validate:"max=255"`
}

type PublisherPost added in v0.5.1

type PublisherPost struct {
	CodeHosting  []CodeHosting `json:"codeHosting" validate:"required,gt=0,dive"`
	Description  string        `json:"description"`
	Email        string        `json:"email" validate:"email,required"`
	Active       *bool         `json:"active"`
	ExternalCode string        `json:"externalCode" validate:"max=255"`
}

type Response

type Response struct {
	Data any `json:"data,omitempty"`
}

func NewResponse

func NewResponse(data any) *Response

type SoftwarePatch added in v0.5.0

type SoftwarePatch struct {
	URL           string    `json:"url" validate:"url"`
	Aliases       *[]string `json:"aliases" validate:"omitempty,dive,url"`
	PubliccodeYml string    `json:"publiccodeYml"`
	Active        *bool     `json:"active"`
}

type SoftwarePost added in v0.5.0

type SoftwarePost struct {
	URL           string   `json:"url" validate:"required,url"`
	Aliases       []string `json:"aliases" validate:"dive,url"`
	PubliccodeYml string   `json:"publiccodeYml" validate:"required"`
	Active        *bool    `json:"active"`
}

type ValidationError

type ValidationError struct {
	Field string `json:"field"`
	Rule  string `json:"rule"`
	Value string `json:"value,omitempty"`
}

func ValidateStruct

func ValidateStruct(validateStruct interface{}) []ValidationError

type Webhook added in v0.3.0

type Webhook struct {
	URL    string `json:"url" validate:"required,url"`
	Secret string `json:"secret"`
}

Jump to

Keyboard shortcuts

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