feat: add GetAuthTokenFromContext
This commit is contained in:
parent
93105fe5af
commit
26a6bda053
|
@ -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():
|
||||||
|
|
Loading…
Reference in New Issue