middleware

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearSessionCookie

func ClearSessionCookie(w http.ResponseWriter)

ClearSessionCookie removes the session cookie.

func Recovery added in v0.41.0

func Recovery(next http.Handler) http.Handler

Recovery returns middleware that recovers from panics, logs the stack trace, and returns HTTP 500 to the client instead of crashing the server.

func RequireAuth

func RequireAuth(db *sql.DB, loginURL string) func(http.Handler) http.Handler

RequireAuth validates the session cookie and injects the tenant into context. Redirects to loginURL if no valid session is found.

func SessionCookieName

func SessionCookieName() string

SessionCookieName returns the session cookie name based on the BASE_URL scheme.

func SetSessionCookie

func SetSessionCookie(w http.ResponseWriter, token string, maxAge int)

SetSessionCookie sets the session cookie with security attributes.

func TenantFromContext

func TenantFromContext(ctx context.Context) *tenant.Tenant

TenantFromContext extracts the tenant from the request context.

func WithTenantContext added in v0.26.2

func WithTenantContext(ctx context.Context, tn *tenant.Tenant) context.Context

WithTenantContext injects a tenant into the context. Intended for tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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