app

package
v0.0.0-...-d915e1c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const CACHE_TIMEOUT = 20 * time.Second
View Source
const MAX_CACHE_SIZE_MB = 10

Do not store over this amount of MBs in the cache

View Source
const RECAPTCHA_VERIFY_URL string = "https://www.google.com/recaptcha/api/siteverify"

Change this in case Google decides to deprecate the reCAPTCHA validation endpoint

Variables

This section is empty.

Functions

func SetupRoutes

func SetupRoutes(app_settings common.AppSettings, database database.Database) *gin.Engine

Types

type Cache

type Cache interface {
	Get(name string) (EndpointCache, error)
	Store(name string, buffer []byte) error
	Size() uint64
}

func MakeCache

func MakeCache(n_shards int, expiry_duration time.Duration, validator CacheValidator) Cache

type CacheValidator

type CacheValidator interface {
	IsValid(cache *EndpointCache) bool
}

type EndpointCache

type EndpointCache struct {
	Name       string
	Contents   []byte
	ValidUntil time.Time
}

type Generator

type Generator = func(*gin.Context, common.AppSettings, database.Database) ([]byte, error)

type RecaptchaResponse

type RecaptchaResponse struct {
	Success   bool    `json:"success"`
	Score     float32 `json:"score"`
	Timestamp string  `json:"challenge_ts"`
	Hostname  string  `json:"hostname"`
}

type TimeValidator

type TimeValidator struct{}

func (*TimeValidator) IsValid

func (validator *TimeValidator) IsValid(cache *EndpointCache) bool

type TimedCache

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

func (*TimedCache) Get

func (cache *TimedCache) Get(name string) (EndpointCache, error)

func (*TimedCache) Size

func (cache *TimedCache) Size() uint64

func (*TimedCache) Store

func (cache *TimedCache) Store(name string, buffer []byte) error

Jump to

Keyboard shortcuts

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