Documentation
¶
Index ¶
- func BuildContextForUser(ctx context.Context, db *database.Connection, userID int64, ...) context.Context
- func InjectAdmin(ctx context.Context, isAdmin bool) context.Context
- func InjectIntoContext(ctx context.Context, i InjectIntoContextInput) context.Context
- func InjectPolicy(ctx context.Context, p policy.Policy) context.Context
- func InjectUser(ctx context.Context, userID int64) context.Context
- func IsAdmin(ctx context.Context) bool
- func Policy(ctx context.Context) policy.Policy
- func UserID(ctx context.Context) int64
- type InjectIntoContextInput
- type MiddlewareFunc
- type UserData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildContextForUser ¶
func InjectAdmin ¶
InjectAdmin is a helper function to add a flag denoting if the current user is an Administrator
func InjectIntoContext ¶
func InjectIntoContext(ctx context.Context, i InjectIntoContextInput) context.Context
InjectIntoContext adds a collection of data to the appropriate keys into the context.
func InjectPolicy ¶
InjectPolicy is a helper function to add a policy to the context under the expected key
func InjectUser ¶
InjectUser is a helper function to add a user to the context under the expected key
func IsAdmin ¶
IsAdmin is used to check if the current user has been identified as an admin. Note that this value will only change when the session store is cleared for this user (i.e. they log out)
Types ¶
type InjectIntoContextInput ¶
InjectIntoContextInput is a small structure for defining what is placed into the context
type MiddlewareFunc ¶
func AuthenticateAppAndInjectCtx ¶
func AuthenticateAppAndInjectCtx(db *database.Connection) MiddlewareFunc
func AuthenticateUserAndInjectCtx ¶
func AuthenticateUserAndInjectCtx(db *database.Connection, sessionStore *session.Store) MiddlewareFunc
func InjectCSRFTokenHeader ¶
func InjectCSRFTokenHeader() MiddlewareFunc
func LogRequests ¶
func LogRequests(baseLogger *slog.Logger) MiddlewareFunc
Click to show internal directories.
Click to hide internal directories.