haixunMaster/haixun-backend/internal/library/authctx/context.go

21 lines
376 B
Go
Raw Normal View History

2026-06-23 09:54:27 +00:00
package authctx
import "context"
type Actor struct {
TenantID string
UID string
JTI string
}
type actorKey struct{}
func WithActor(ctx context.Context, actor Actor) context.Context {
return context.WithValue(ctx, actorKey{}, actor)
}
func ActorFromContext(ctx context.Context) (Actor, bool) {
actor, ok := ctx.Value(actorKey{}).(Actor)
return actor, ok
}