common

package
v1.11.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 9 Imported by: 21

Documentation

Index

Constants

View Source
const (
	RedirectName = "Redirect"
	BaseUrlName  = "BaseUrl"

	UserIdName     = "Id" // current connected user id
	ViewedUserName = "ViewedUser"

	AllowedToCreateName = "AllowedToCreate"
	AllowedToUpdateName = "AllowedToUpdate"
	AllowedToDeleteName = "AllowedToDelete"
)
View Source
const (
	ErrorKey = "error"

	QueryError     = "?" + errorKeyEq
	AddQueryError  = "&" + errorKeyEq
	PathQueryError = "/" + QueryError
)
View Source
const (
	ErrorBadRoleNameKey          = "ErrorBadRoleName"
	ErrorBaseVersionKey          = "BaseVersionOutdated"
	ErrorEmptyCommentKey         = "EmptyComment"
	ErrorEmptyLoginKey           = "EmptyLogin"
	ErrorEmptyPasswordKey        = "EmptyPassword"
	ErrorExistingLoginKey        = "ExistingLogin"
	ErrorNotAuthorizedKey        = "ErrorNotAuthorized"
	ErrorTechnicalKey            = "ErrorTechnicalProblem"
	ErrorUpdateKey               = "ErrorUpdate"
	ErrorWeakPasswordKey         = "WeakPassword"
	ErrorWrongConfirmPasswordKey = "WrongConfirmPassword"
	ErrorWrongLangKey            = "WrongLang"
	ErrorWrongLoginKey           = "WrongLogin"
)

error displayed to user

View Source
const ReportingPlaceName = "reporting_place"
View Source
const WrongLangKey = "WrongLang"

Variables

View Source
var (
	ErrBadRoleName   = errors.New(ErrorBadRoleNameKey)
	ErrBaseVersion   = errors.New(ErrorBaseVersionKey)
	ErrEmptyComment  = errors.New(ErrorEmptyCommentKey)
	ErrEmptyLogin    = errors.New(ErrorEmptyLoginKey)
	ErrEmptyPassword = errors.New(ErrorEmptyPasswordKey)
	ErrExistingLogin = errors.New(ErrorExistingLoginKey)
	ErrNotAuthorized = errors.New(ErrorNotAuthorizedKey)
	ErrTechnical     = errors.New(ErrorTechnicalKey)
	ErrUpdate        = errors.New(ErrorUpdateKey)
	ErrWeakPassword  = errors.New(ErrorWeakPasswordKey)
	ErrWrongConfirm  = errors.New(ErrorWrongConfirmPasswordKey)
	ErrWrongLogin    = errors.New(ErrorWrongLoginKey)
)

Functions

func CheckPort added in v1.8.3

func CheckPort(port string) string

func CreateRedirect

func CreateRedirect(redirecter Redirecter) gin.HandlerFunc

func CreateRedirectString

func CreateRedirectString(target string) gin.HandlerFunc

func DefaultErrorRedirect

func DefaultErrorRedirect(logger log.Logger, errorMsg string) string

func FilterErrorMsg added in v1.10.0

func FilterErrorMsg(logger log.Logger, errorMsg string) string

func FilterExtractHtml added in v0.2.0

func FilterExtractHtml(html string, extractSize uint64) string

html must be well formed

func GetBaseUrl

func GetBaseUrl(levelToErase uint8, c *gin.Context) string

func GetCurrentUrl

func GetCurrentUrl(c *gin.Context) string

func GetPagination

func GetPagination(defaultPageSize uint64, c *gin.Context) (uint64, uint64, uint64, string)

func InitPagination

func InitPagination(data gin.H, filter string, pageNumber uint64, end uint64, total uint64)

func LogOriginalError

func LogOriginalError(logger log.Logger, err error)

func MapToValueSlice

func MapToValueSlice[K comparable, V any](objects map[K]V) []V

func WriteError

func WriteError(urlBuilder *strings.Builder, logger log.Logger, errorMsg string)

Types

type DataAdder

type DataAdder func(gin.H, *gin.Context)

type LocalesManager added in v1.10.3

type LocalesManager interface {
	GetDefaultLang() string
	GetAllLang() []string
	GetMultipleLang() bool
	GetLang(*gin.Context) string
	CheckLang(string, *gin.Context) string
	SetLangCookie(string, *gin.Context) string
}

type Redirecter

type Redirecter func(*gin.Context) string

type Set

type Set[V comparable] map[V]empty

func MakeSet

func MakeSet[V comparable](values []V) Set[V]

func (Set[V]) Add

func (s Set[V]) Add(value V)

func (Set[V]) Contains

func (s Set[V]) Contains(value V) bool

func (Set[V]) Remove

func (s Set[V]) Remove(value V)

func (Set[V]) Slice

func (s Set[V]) Slice() []V

type Stack added in v0.2.0

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func NewStack added in v0.2.0

func NewStack[T any]() *Stack[T]

func (*Stack[T]) Empty added in v0.2.0

func (s *Stack[T]) Empty() bool

func (*Stack[T]) Peek added in v0.2.0

func (s *Stack[T]) Peek() T

func (*Stack[T]) Pop added in v0.2.0

func (s *Stack[T]) Pop() T

func (*Stack[T]) Push added in v0.2.0

func (s *Stack[T]) Push(e T)

type TemplateRedirecter

type TemplateRedirecter func(gin.H, *gin.Context) (string, string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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