middlewares

package
v0.249.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalizeListFilters added in v0.221.2

func CanonicalizeListFilters(session handlers.SessionManager) func(next http.Handler) http.Handler

CanonicalizeListFilters handles processing and storing the fully-specified, whitelisted list filters for the user.

func CanonicalizeSearchParams added in v0.221.2

func CanonicalizeSearchParams(session handlers.SessionManager) func(next http.Handler) http.Handler

CanonicalizeSearchParams processes and stores the search params requested by a user.

func DetectClient added in v0.154.0

func DetectClient(req *http.Request) models.ClientType

DetectClient detects the type of client accessing the app.

func ExtractUserFromSession added in v0.143.0

func ExtractUserFromSession(
	users UserService,
	auth Authenticator,
	session SessionManager,
) func(next http.Handler) http.Handler

ExtractUserFromSession will make sure the session has a usable access token (refreshing it if needed), extract the user data from the session, retrieve the user details from the backend and then store the user object in the context for use by later handlers.

NOTE: the old SkipUpdatesRoute step was removed. It never called next (so matching routes got an empty 200) and it wrote a "100 Continue" header on every other request. If some routes must bypass authentication, mount them outside the router group that uses this middleware.

func Logger

func Logger(next http.Handler) http.Handler

func NoCache added in v0.212.0

func NoCache(next http.Handler) http.Handler

NoCache ensures no caching will be applied.

func Otel added in v0.61.0

func Otel(next http.Handler) http.Handler

Otel is a middleware to configure open telemetry for the server.

func Recoverer added in v0.134.0

func Recoverer(next http.Handler) http.Handler

Recoverer is a modified version of the standard chi Recoverer middleware that additional logs to the GCP error console.

func RequireValidUser added in v0.143.0

func RequireValidUser(next http.Handler) http.Handler

RequireValidUser will ensure that protected routes have a valid user status before continuing.

func SetClient added in v0.154.0

func SetClient(next http.Handler) http.Handler

SetClient is a middleware that detects and sets a client variable in the context.

Types

type AppConfig added in v0.235.0

type AppConfig interface {
	GetAppID() string
	GetAppVersion() string
	GetAppName() string
	GetAppEnvironment() config.Environment
	IsProduction() bool
	GetBaseURL() *url.URL
}

type Authenticator added in v0.244.3

type Authenticator interface {
	IsAuthenticated(ctx context.Context) bool
	GenerateAuthURL(signup bool) (*auth0.AuthURLResult, error)
	StoreAuthRequest(ctx context.Context, r *auth0.AuthURLResult)
	ValidateState(ctx context.Context, got string) error
	PerformExchange(ctx context.Context, code string) (*models.UserProfileResponse, error)
	EnsureFresh(ctx context.Context) error
	PutReturnTo(ctx context.Context, path string)
	ConsumeReturnTo(ctx context.Context) (string, error)
	GenerateLogoutURL() (*url.URL, error)
	ClearAuth(ctx context.Context)
}

type SessionManager added in v0.244.3

type SessionManager interface {
	Get(ctx context.Context, key string) any
	Put(ctx context.Context, key string, value any)
	Remove(ctx context.Context, key string)
	RenewToken(ctx context.Context) error
	Clear(ctx context.Context) error
}

type UserService added in v0.235.0

type UserService interface {
	GetUserByExternalID(ctx context.Context, externalID string) (*models.User, error)
}

Jump to

Keyboard shortcuts

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