modulepackage
1.0.1
Repository: https://github.com/aaronland/go-http-cookie.git
Documentation: pkg.go.dev
# README
go-http-cookie
Go package for working with HTTP cookies.
Documentation
Example
Error handling omitted for the sake of brevity.
package main
import (
"fmt"
"github.com/aaronland/go-http-cookie"
)
func main() {
name := "c"
secret := "s33kret"
salt := "s4lty"
cookie_uri := fmt.Sprintf("encrypted://?name=%s&secret=%s&salt=%s", name, secret, salt)
ck, _ := cookie.NewCookie(ctx, cookie_uri)
}
See also
# Packages
No description provided by the author
# Functions
NewCookie() returns a new instance of `Cookie` for the scheme associated with 'uri'.
NewEncryptedCookie() returns a new `EncryptedCookie` instance derived from 'uri' which is expected to take the form of:
encrypted://?name={NAME}&secret={SECRET}&salt={SECRET}
Where `{NAME}` is the name of the cookie for all subsequent operations; `{SECRET}` is the secret key used to encrypt the value of the cookie; `{SALT}` is the salt used to encrypt the cookie.
NewRandomEncryptedCookieSalt returns a random salt value suitable for `encrypted://` cookie URIs.
NewRandomEncryptedCookieSecret returns a random salt value suitable for `encrypted://` cookie URIs.
NewRandomEncryptedCookieURI() returns a new URI for creating an `EncryptedCookie` instance for 'name' with random values for the required secret and salt.
RegisterCookie() associates 'scheme' with 'f' in an internal list of avilable `Cookie` implementations.
Schemes() returns the list of schemes that have been "registered".
# Structs
EncryptedCookie implements the `Cookie` interface for working with cookies whose values have been encrypted.
# Interfaces
Cookie is an interface for working with HTTP cookies.
# Type aliases
CookieInitializeFunc is a function used to initialize an implementation of the `Cookie` interface.