middleware

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Simple in-memory Cache with TTL (Time to Live) support. Intended to be used to store static information e.g., HoYoWiki data.

func NewCache

func NewCache() *Cache

Constructor. Cache has a default TTL of 1 minute.

func (*Cache) Get

func (c *Cache) Get(k string) any

Get an item from the cache. Returns the value or nil, and a bool indicating if the value is found, or if it has expired.

func (*Cache) Remove

func (c *Cache) Remove(k string)

Removes item from the cache.

func (*Cache) Set

func (c *Cache) Set(k string, v any)

Adds an item to the cache using the default TTL. Replaces existing item if the key exists.

func (*Cache) SetCacheDuration

func (c *Cache) SetCacheDuration(d time.Duration)

Set the default TTL of the cache.

func (*Cache) SetWithTTL

func (c *Cache) SetWithTTL(k string, v any, d time.Duration)

Adds an item to the cache with a custom TTL. Replaces existing item if the key exists.

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

Cookie data class that stores tokens required for calling HoYoLab endpoints.

func NewCookie

func NewCookie(ltokenV2 string, ltmidV2 string, ltuidV2 string) Cookie

Constructor.

func (Cookie) ParseCookie

func (cookie Cookie) ParseCookie() string

Converts cookie tokens into a string to be added into a request header. Each token is separated by semicolons. Similar to http.Request.AddCookie().

func (Cookie) Tokens

func (cookie Cookie) Tokens() []http.Cookie

Return all cookie tokens as an array.

Jump to

Keyboard shortcuts

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