session

package
v0.0.0-...-644ba59 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_SESSION_NAME string = "gopher.sid"
View Source
const REQUEST_CONTEXT_SESSION_ID = "sessionID"

Variables

View Source
var DISABLE_RESAVE = flag.Bool("DISABLE_RESAVE", false, "")
View Source
var DISABLE_SAVE_UNINITIALIZED = flag.Bool("DISABLE_SAVE_UNINITIALIZED", false, "")
View Source
var ENABLE_RESAVE = flag.Bool("ENABLE_RESAVE", true, "")
View Source
var ENABLE_SAVE_UNINITIALIZED = flag.Bool("ENABLE_SAVE_UNINITIALIZED", true, "")

Functions

This section is empty.

Types

type HTTPCookie

type HTTPCookie struct {
	http.Cookie
	SameSite SameSite
}

HTTPCookie comment

func (*HTTPCookie) String

func (c *HTTPCookie) String() string

String returns the serialization of the cookie for use in a Cookie header (if only Name and Value are set) or a Set-Cookie response header (if other fields are set). If c is nil or c.Name is invalid, the empty string is returned.

type MemoryStore

type MemoryStore struct {
	StoreInterface
	Store
}

MemoryStore comment

func (*MemoryStore) SetSession

func (ctx *MemoryStore) SetSession(sess *Session)

SetSession comment

type Middleware

type Middleware struct {
	SessionID string
	Store     *interface{ StoreInterface }

	MiddlewareOptions
	IsResave            bool
	IsSaveUninitialized bool
	Secret              []string
	// contains filtered or unexported fields
}

Middleware comment

func NewMiddleware

func NewMiddleware(handler http.Handler, opts *MiddlewareOptions) (*Middleware, error)

NewMiddleware create new session middleware

func (*Middleware) ServeHTTP

func (ctx *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MiddlewareOptions

type MiddlewareOptions struct {
	Cookie              *HTTPCookie                  `json:"cookie"`
	Name                string                       `json:"name"`
	Store               *interface{ StoreInterface } `json:"store"`
	IsTrustProxy        bool                         `json:"proxy"`
	IsResave            *bool                        `json:"resave"`
	IsRolling           bool                         `json:"rolling"`
	IsSaveUninitialized *bool                        `json:"saveUninitialized"`
	UnsetMode           *UnsetMode                   `json:"unset"`
	Secret              *[]string                    `json:"secret"`
}

MiddlewareOptions comment

type SameSite

type SameSite int
const (
	SameSiteDefaultMode SameSite = iota + 1
	SameSiteLaxMode
	SameSiteStrictMode
)

type Session

type Session struct {
	ID      string
	Request *http.Request
	Cookie  *HTTPCookie
}

Session comment

func GenerateNewSession

func GenerateNewSession(r *http.Request, isTrustProxy bool) (*Session, error)

GenerateNewSession comment

type Store

type Store struct {
	StoreInterface
	Session *Session
}

Store comment

func (*Store) SetSession

func (ctx *Store) SetSession(sess *Session)

SetSession comment

type StoreInterface

type StoreInterface interface {
	SetSessionGenerator(func(*http.Request, bool) (*Session, error))
}

StoreInterface comment

type UnsetMode

type UnsetMode string
const (
	UNSET_KEEP    UnsetMode = "keep"
	UNSET_DESTROY UnsetMode = "destroy"
)

Jump to

Keyboard shortcuts

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