Documentation
¶
Index ¶
- Constants
- Variables
- func AuthUser(ctx context.Context) (*entity.User, error)
- func NewContextWithTags(ctx context.Context, tags []string) context.Context
- func NewContextWithUser(ctx context.Context, user *entity.User) context.Context
- func TagsFromContext(ctx context.Context) []string
- func UserFromContext(ctx context.Context) *entity.User
- func UserIDFromContext(ctx context.Context) int64
Constants ¶
const ( ContextTagGeneric = "generic" ContextTagHTTP = "HTTP" ContextTagMGVM = "MGVM" ContextTagCLI = "CLI" ContextParamClaims = "claims" )
Variables ¶
var ( // Commit is the current commit of the application. Commit string // ReleaseVersion is the current release version of the application. ReleaseVersion string // ReleaseCreatedAt is the date of the current release. ReleaseCreatedAt string )
Functions ¶
func AuthUser ¶ added in v0.0.7
AuthUser returns the current authenticated user from the context. Returns EUNAUTHORIZED error if no user is found in the context.
func NewContextWithTags ¶
NewContextWithTag returns a new context with the provided tag attached. This can be useful during logging to define in which context a log entry was created, for example, HTTP, cron, CLI, etc.
func NewContextWithUser ¶
NewContextWithUser returns a new context with the provided user attached.
func TagsFromContext ¶
TagsFromContext returns the tags stored in the provided context. If no tags are stored in the context, a slice with a single generic tag is returned.
func UserFromContext ¶
UserFromContext returns the user stored in the provided context.
func UserIDFromContext ¶
UserIDFromContext returns the user ID stored in the provided context.
Types ¶
This section is empty.