common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SymmetricKeyLen = 32
)

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")
)

Functions

func CustomErrorHandler

func CustomErrorHandler(ctx *fiber.Ctx, err error) 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"`
}

type Environment

type Environment struct {
	MaxRequests        int        `env:"MAX_REQUESTS" envDefault:"20"`
	CurrentEnvironment string     `env:"ENVIRONMENT" envDefault:"local"`
	Database           string     `env:"DATABASE_DSN"`
	PasetoKey          *Base64Key `env:"PASETO_KEY"`
}

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 Publisher

type Publisher struct {
	URL         string `json:"url" validate:"required"`
	Description string `json:"description"`
	Email       string `json:"email" validate:"email"`
}

type PublisherUpdate

type PublisherUpdate struct {
	CodeHosting []CodeHosting `json:"codeHosting" validate:"required"`
	Description string        `json:"description"`
	Email       string        `json:"email" validate:"email"`
}

type Response

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

func NewResponse

func NewResponse(data any) *Response

type Software

type Software struct {
	URLs          []string `json:"urls" validate:"required,gt=0"`
	PubliccodeYml string   `json:"publiccodeYml" validate:"required"`
}

type ValidationError

type ValidationError struct {
	FailedField string `json:"field"`
	Tag         string `json:"rule"`
	Value       string `json:"providedValue"`
}

func ValidateStruct

func ValidateStruct(s interface{}) []ValidationError

Jump to

Keyboard shortcuts

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