internal

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CookieMaxAgeInSeconds = 60 * 60 * 24 * 7 * 3 // 3 weeks
	CookieName            = "sizeIt"

	KeyUser contextKey = 1
)
View Source
const (
	LogKeyError   = "error"
	LogKeyEvent   = "event"
	LogKeyLatency = "latency"
	LogKeyMethod  = "method"
	LogKeyURI     = "uri"
	LogKeySession = "session"
	LogKeyStatus  = "status"
	LogKeyUser    = "user"
)

Variables

View Source
var (
	ErrInvalidInput = errors.New("invalid input")
	ErrUnauthorized = errors.New("unauthorized")
	ErrNotFound     = errors.New("not found")
)

Functions

func Bind

func Bind[T any](c echo.Context) (T, error)

func ConfigureLogs

func ConfigureLogs(dev bool)

func LogError

func LogError(msg string, err error)

func SetCookie

func SetCookie(c echo.Context, usr User) error

Types

type Clock

type Clock interface {
	Now() time.Time
}

type Config

type Config struct {
	DatabaseURL       string
	Dev               bool
	EmptySessionsTick time.Duration `envDefault:"1h"`
	Host              string
	MaxInactiveTime   time.Duration `envDefault:"5s"`
	Path              string
	Port              int `envDefault:"8080"`
}

func ParseConfig

func ParseConfig() (Config, error)

func (Config) Address

func (cfg Config) Address() string

type FixedClock

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

func NewFixedClock

func NewFixedClock(now time.Time) FixedClock

func (FixedClock) Now

func (clk FixedClock) Now() time.Time

type UTCClock

type UTCClock struct{}

func (*UTCClock) Now

func (clk *UTCClock) Now() time.Time

type User

type User struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Team string `json:"team"`
}

func GetUser

func GetUser(ctx context.Context) (User, error)

func (User) Equals added in v0.0.4

func (usr User) Equals(other User) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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