app

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextTagGeneric = "generic"
	ContextTagHTTP    = "HTTP"
	ContextTagMGVM    = "MGVM"
	ContextTagCLI     = "CLI"

	ContextParamClaims = "claims"
)

Variables

View Source
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

func AuthUser(ctx context.Context) (*entity.User, error)

AuthUser returns the current authenticated user from the context. Returns EUNAUTHORIZED error if no user is found in the context.

func NewContextWithTags

func NewContextWithTags(ctx context.Context, tags []string) context.Context

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

func NewContextWithUser(ctx context.Context, user *entity.User) context.Context

NewContextWithUser returns a new context with the provided user attached.

func TagsFromContext

func TagsFromContext(ctx context.Context) []string

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

func UserFromContext(ctx context.Context) *entity.User

UserFromContext returns the user stored in the provided context.

func UserIDFromContext

func UserIDFromContext(ctx context.Context) int64

UserIDFromContext returns the user ID stored in the provided context.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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