Documentation
¶
Index ¶
- Constants
- Variables
- func SetDOMCookie(name, value string)
- type Cookie
- type CookieJar
- func (cj *CookieJar) All() []*Cookie
- func (cj *CookieJar) AsJson(cookies ...string) ([]byte, error)
- func (cj *CookieJar) AsMap(cookies ...string) map[string]string
- func (cj *CookieJar) DelCookie(name string) error
- func (cj *CookieJar) DelCookieIndex(index int) error
- func (cj *CookieJar) Dump(r *http.Request, cookies ...string) error
- func (cj *CookieJar) DumpForm(rq *http.Request, cookies ...string)
- func (cj *CookieJar) DumpJson(rq *http.Request, cookies ...string) error
- func (cj *CookieJar) Get(name string) (*Cookie, error)
- func (cj *CookieJar) SetCookie(cookie *Cookie) error
- func (cj *CookieJar) SetHTTPCookie(cookie *http.Cookie) error
- func (cj *CookieJar) SetHTTPCookies(cookies []*http.Cookie) error
- func (cj *CookieJar) Stop()
- type SameSite
Examples ¶
Constants ¶
View Source
const (
MaxAgeNotSet = 0
)
Variables ¶
View Source
var GlobalJar = NewCookieJar()
Functions ¶
func SetDOMCookie ¶
func SetDOMCookie(name, value string)
Types ¶
type Cookie ¶
type Cookie struct {
Name string
Value string
Path string
Domain string
Expires time.Time
// MaxAge=0 means no 'Max-Age' attribute specified.
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
// MaxAge>0 means Max-Age attribute present and given in seconds
MaxAge int
Secure bool
HttpOnly bool
SameSite SameSite
Raw string
CalledCloseToExpire bool
}
func GetDOMCookie ¶
type CookieJar ¶
type CookieJar struct {
OnExpire func(cookie *Cookie)
CloseToExpire func(cookie *Cookie)
CloseToExpireTimeSeconds int
// contains filtered or unexported fields
}
Example ¶
package main
import (
"time"
"github.com/Nigel2392/htmlgen/cookies"
)
var CookieJAR = cookies.NewCookieJar()
func main() {
CookieJAR.SetCookie(&cookies.Cookie{
Name: "test",
Value: "test",
Path: "/",
Domain: "localhost",
Expires: time.Now().Add(1 * time.Hour),
MaxAge: 3600,
Secure: false,
HttpOnly: false},
)
}
func NewCookieJar ¶
func NewCookieJar() *CookieJar
func (*CookieJar) DelCookieIndex ¶
func (*CookieJar) SetHTTPCookies ¶
Click to show internal directories.
Click to hide internal directories.