session

package
v0.0.0-...-c265b2b Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package session manages the session configuration for a given host.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSession = errors.New("no session")

ErrNoSession is returned when a session does not exist for a given host.

Functions

func IsWritableHeader

func IsWritableHeader(h string) bool

IsWritableHeader returns whether or not a header is writable.

func SessionsPath

func SessionsPath() string

SessionsPath returns the path to the sessions configuration file.

func WriteConfig

func WriteConfig(cfg *Config) error

WriteConfig writes the configuration file.

func WriteSession

func WriteSession(name string, req *http.Request, opts WriteSessionOpts) error

WriteSession writes a session to the configuration file for the given request.

Types

type Config

type Config struct {
	Sessions map[string]Session `json:"sessions"`
}

A Config represents the overall configuration file that stores all sessions.

func ReadConfig

func ReadConfig() (*Config, error)

ReadConfig returns the configuration file.

type Session

type Session struct {
	Headers map[string][]string `json:"headers"`
	Scheme  string              `json:"scheme"`
}

A Session represents a single session configuration.

func NewSession

func NewSession() *Session

NewSession returns a new empty session.

func ReadSession

func ReadSession(name string) (*Session, error)

ReadSession reads a session from the configuration file for the given request.

When no session is found an empty session and ErrNoSession are returned.

type WriteSessionOpts

type WriteSessionOpts struct {
	// SaveAllHeaders specifies whether or not all headers should be saved.
	SaveAllHeaders bool
}

WriteSessionOpts are options for writing a session.

Jump to

Keyboard shortcuts

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