api

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const CacheGetPath = "/{any:*}"

CacheGetPath for getting pagedata from cache via HTTP.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheController

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

CacheController handles cache API requests (read/write-through, error reporting, metrics).

func NewCacheController

func NewCacheController(
	ctx context.Context,
	cfg *config.Cache,
	cache storage.Storage,
	metrics metrics.Meter,
	backend repository.Backender,
) *CacheController

NewCacheController builds a cache API controller with all dependencies. If debug is enabled, launches internal stats logger goroutine.

func (*CacheController) AddRoute

func (c *CacheController) AddRoute(router *router.Router)

AddRoute attaches controller's route(s) to the provided router.

func (*CacheController) Index

func (c *CacheController) Index(r *fasthttp.RequestCtx)

Index is the main HTTP handler.

type ClearController added in v0.9.7

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

func NewClearController added in v0.9.7

func NewClearController(cfg *config.Cache, db storage.Storage) *ClearController

func (*ClearController) AddRoute added in v0.9.7

func (c *ClearController) AddRoute(r *router.Router)

func (*ClearController) HandleClear added in v0.9.7

func (c *ClearController) HandleClear(ctx *fasthttp.RequestCtx)

HandleClear is mounted at GET /cache/clear. Without ?token, returns a valid token (5min TTL). With ?token, validates, clears storage, logs, and returns status.

type OnOffController added in v0.9.7

type OnOffController struct{}

OnOffController provides endpoints to switch the advanced cache on and off.

func NewOnOffController added in v0.9.7

func NewOnOffController() *OnOffController

NewOnOffController creates a new OnOffController instance.

func (*OnOffController) AddRoute added in v0.9.7

func (c *OnOffController) AddRoute(r *router.Router)

AddRoute attaches the on/off routes to the given router.

func (*OnOffController) Off added in v0.9.7

func (c *OnOffController) Off(ctx *fasthttp.RequestCtx)

Off handles POST /adv-cache/off and disables the advanced cache, returning JSON.

func (*OnOffController) On added in v0.9.7

func (c *OnOffController) On(ctx *fasthttp.RequestCtx)

On handles POST /adv-cache/on and enables the advanced cache, returning JSON.

Jump to

Keyboard shortcuts

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