package domain

import (
	"context"
	"errors"
)

type User struct {
	ID   int
	Name string
}

func FromContext(ctx context.Context) (*User, error) {
	u, ok := ctx.Value("ID").(*User)
	if !ok {
		return nil, errors.New("user not found")
	}

	return u, nil
}

func WithContext(ctx context.Context, u *User) context.Context {
	return context.WithValue(ctx, "ID", u)
}
