modelRT/diagram/context.go

21 lines
413 B
Go
Raw Normal View History

package diagram
import (
"context"
"fmt"
"modelRT/common"
"modelRT/constants"
)
func clientTokenFromContext(ctx context.Context) (string, error) {
if ctx == nil {
return "", common.ErrGetClientToken
}
token, ok := ctx.Value(constants.CtxKeyClientToken).(string)
if !ok || token == "" {
return "", fmt.Errorf("%w: missing or invalid context value", common.ErrGetClientToken)
}
return token, nil
}