Documentation
¶
Overview ¶
Package session persists values captured from responses between apic invocations, so `apic run login` followed by `apic run get-user` works the way it does in a GUI client. State lives in .apic/session.json under the project root; the directory ignores itself via .apic/.gitignore.
Index ¶
Constants ¶
const ( Dir = ".apic" File = "session.json" DefaultEnv = "default" )
const CookieFile = "cookies.json"
CookieFile holds the cookie jar, beside session.json.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cookie ¶
type Cookie struct {
Name string `json:"name"`
Value string `json:"value"`
Domain string `json:"domain"`
Path string `json:"path"`
Expires time.Time `json:"expires,omitzero"`
Secure bool `json:"secure,omitempty"`
HTTPOnly bool `json:"http_only,omitempty"`
HostOnly bool `json:"host_only,omitempty"`
}
Cookie is one stored cookie. Domain, Path and HostOnly are the jar's view after the RFC 6265 defaults were applied, so a saved cookie is sent to the same hosts after a restart as before it. A zero Expires means the cookie lives until `apic session clear`: apic keeps a login's session cookie for the same reason it keeps a captured token.
type EnvJar ¶
type EnvJar struct {
// contains filtered or unexported fields
}
EnvJar is the http.CookieJar of one environment. It wraps a net/http/cookiejar and records every cookie the server sets, since the standard jar cannot be enumerated for saving.
type Jar ¶
type Jar struct {
// contains filtered or unexported fields
}
Jar is the cookie jar of a project, one set of cookies per environment, stored in .apic/cookies.json next to the session. The runtime behaviour is net/http/cookiejar's, without a public-suffix list: a project that talks to one API has no need for one, and it keeps the binary small.
func NewMemoryJar ¶
func NewMemoryJar() *Jar
NewMemoryJar returns a jar that is never written to disk.
func (*Jar) Cookies ¶
Cookies lists the unexpired cookies stored for env, sorted by domain, path and name.
type Store ¶
type Store struct {
Envs map[string]map[string]string `json:"envs"`
// contains filtered or unexported fields
}
Store is the on-disk session.
func NewMemory ¶
func NewMemory() *Store
NewMemory returns a session that is never written to disk. Captured values and cached tokens still work within the process.
func (*Store) Save ¶
Save writes the session to disk, creating .apic/ and its .gitignore. A memory-only store is a no-op.