cookie

package
v0.0.0-...-2bf1e3b Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CookieTool

type CookieTool struct {
	// Returns a list of cipher.Block object that should be used for
	// processing cookies. Cookies will be decrypted with all the keys
	// in order to find one that is valid and will be encrypted with the
	// first in the list. This allows rotation of keys without disruption.
	AESKeys func(context.Context) ([]cipher.Block, error)
}

Handles the encrypting and decrypting of data in cookies.

func (*CookieTool) Decode

func (c *CookieTool) Decode(
	ctx context.Context,
	cookie string,
	v interface{},
) error

Decodes the given cookie contents into the given interface value. If the cookie is not valid or can not be decoded then an error will be returned.

func (*CookieTool) Encode

func (c *CookieTool) Encode(
	ctx context.Context,
	v interface{},
) (
	string,
	error,
)

Like decodeCookie except this is used for encoding.

type Time

type Time struct {
	time.Time
}

Acts like a time.Time object, but encodes to and from a unix epoch to save space. Because this converts to float and back it will lose precision in the sub-second values, typically at most in the micro second range.

func (*Time) MarshalText

func (t *Time) MarshalText() ([]byte, error)

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(raw []byte) error

Jump to

Keyboard shortcuts

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