feat: add GetAuthTokenFromContext

This commit is contained in:
Derrick Hammer 2024-03-18 17:18:26 -04:00
parent 93105fe5af
commit 26a6bda053
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 0 deletions

View File

@ -194,6 +194,17 @@ func GetUserFromContext(ctx context.Context, key ...string) uint {
return userId return userId
} }
func GetAuthTokenFromContext(ctx context.Context) string {
authToken, ok := ctx.Value(AUTH_TOKEN_CONTEXT_KEY).(string)
if !ok {
panic("auth token stored in context is not of type string")
}
return authToken
}
func CtxAborted(ctx context.Context) bool { func CtxAborted(ctx context.Context) bool {
select { select {
case <-ctx.Done(): case <-ctx.Done():