appctx

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

View Source
const (
	UserAgentHeader = "x-user-agent"

	WebUserAgent     = "web"
	GrpcUserAgent    = "grpc"
	MobileUserAgent  = "mobile"
	DesktopUserAgent = "desktop"
)

UserAgentHeader is the header used for the user agent.

View Source
const ResoucePathCtx = "resource_path"

ResoucePathCtx is the key used in the opaque id for passing the resource path.

View Source
const TokenHeader = "x-access-token"

TokenHeader is the header to be used across grpc and http services to forward the access token.

Variables

This section is empty.

Functions

func ContextGetClean

func ContextGetClean(ctx context.Context) context.Context

ContextGetClean returns a new, clean context derived by the given one.

func ContextGetResourcePath

func ContextGetResourcePath(ctx context.Context) (string, bool)

ContextGetResourcePath returns the resource path if set in the given context.

func ContextGetScopes

func ContextGetScopes(ctx context.Context) (map[string]*authpb.Scope, bool)

ContextGetScopes returns the scopes if set in the given context.

func ContextGetToken

func ContextGetToken(ctx context.Context) (string, bool)

ContextGetToken returns the token if set in the given context.

func ContextGetUser

func ContextGetUser(ctx context.Context) (*userpb.User, bool)

ContextGetUser returns the user if set in the given context.

func ContextGetUserAgent

func ContextGetUserAgent(ctx context.Context) (*ua.UserAgent, bool)

ContextGetUserAgent returns the user agent if set in the given context. see https://github.com/grpc/grpc-go/issues/1100

func ContextGetUserAgentCategory

func ContextGetUserAgentCategory(ctx context.Context) (string, bool)

ContextGetUserAgentCategory returns the category of the user agent (i.e. if it is a web, mobile, desktop or grpc user agent).

func ContextGetUserAgentString

func ContextGetUserAgentString(ctx context.Context) (string, bool)

ContextGetUserAgentString returns the user agent string if set in the given context.

func ContextGetUserID

func ContextGetUserID(ctx context.Context) (*userpb.UserId, bool)

ContextGetUserID returns the user if set in the given context.

func ContextMustGetToken

func ContextMustGetToken(ctx context.Context) string

ContextMustGetToken panics if token is not in context.

func ContextMustGetUser

func ContextMustGetUser(ctx context.Context) *userpb.User

ContextMustGetUser panics if user is not in context.

func ContextSetResourcePath

func ContextSetResourcePath(ctx context.Context, path string) context.Context

ContextGetResourcePath stores the resource path in the context.

func ContextSetScopes

func ContextSetScopes(ctx context.Context, scopes map[string]*authpb.Scope) context.Context

ContextSetScopes stores the scopes in the context.

func ContextSetToken

func ContextSetToken(ctx context.Context, t string) context.Context

ContextSetToken stores the token in the context.

func ContextSetUser

func ContextSetUser(ctx context.Context, u *userpb.User) context.Context

ContextSetUser stores the user in the context.

func ContextSetUserID

func ContextSetUserID(ctx context.Context, id *userpb.UserId) context.Context

ContextSetUserID stores the userid in the context.

func GetLogger

func GetLogger(ctx context.Context) *zerolog.Logger

GetLogger returns the logger associated with the given context or a disabled logger in case no logger is stored inside the context.

func WithLogger

func WithLogger(ctx context.Context, l *zerolog.Logger) context.Context

WithLogger returns a context with an associated logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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