utils

package
v0.0.0-...-dd40e37 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SingletonInjector = NewInjector()

SingletonInjector is the global instance of Injector

Functions

func CookieUpdate

func CookieUpdate(c *fiber.Ctx, user userModel.User) error

func Filter

func Filter[T any](slice []T, condition func(T) bool) []T

func Find

func Find[T any](slice []T, condition func(T) bool) *T

func GetUserCache

func GetUserCache(email string) *userModel.User

func Includes

func Includes[T any](slice []T, condition func(T) bool) bool

func Map

func Map[T any, R any](slice []T, transform func(T) R) []R

func ParseBody

func ParseBody[T any](c *fiber.Ctx) (*T, error)

func UpdateUsersCache

func UpdateUsersCache(user userModel.User) bool

func ValidateStruct

func ValidateStruct(s interface{}) error

Types

type Injector

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

Injector struct to hold the singleton objects

func NewInjector

func NewInjector() *Injector

NewInjector creates a new Injector instance

func (*Injector) Bind

func (i *Injector) Bind(singleton interface{}, name string) bool

Bind puts a singleton into memory

func (*Injector) Clear

func (i *Injector) Clear()

Clear removes all singletons from memory

func (*Injector) Delete

func (i *Injector) Delete(name string) bool

Delete removes a singleton from memory

func (*Injector) Get

func (i *Injector) Get(name string) interface{}

Get requests the singleton with the given name

func (*Injector) Update

func (i *Injector) Update(singleton interface{}, name string) bool

Update updates a singleton in memory

Jump to

Keyboard shortcuts

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