middleware

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartSession

func StartSession(manager *sessions.Manager, driver ...string) func(next http.Handler) http.Handler

StartSession is an example middleware that starts a session for each request. If this middleware not suitable for your application, you can create your own.

func StartSessionWithConfig added in v1.5.0

func StartSessionWithConfig(manager *sessions.Manager, cfg Config) func(next http.Handler) http.Handler

StartSessionWithConfig is StartSession with explicit configuration.

The session cookie is (re)sent on every response whose session was saved successfully, so its expiry slides along with the server-side lifetime. For streaming responses the session is saved right before the first byte goes out; changes made after that are still persisted when the handler returns, but can no longer affect the cookie.

Types

type Config added in v1.5.0

type Config struct {
	// Driver is the session driver name; empty selects the default driver.
	Driver string
	// Cookie, when set, is called with the prepared session cookie before it
	// is written, allowing customization of Path, Domain, Secure, SameSite
	// and the other attributes.
	Cookie func(*http.Cookie)
}

Config customizes the StartSession middleware.

Jump to

Keyboard shortcuts

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