24 lines
429 B
Go

package context
import (
"context"
"forge.cadoles.com/wpetit/clearcase/internal/core/model"
"github.com/pkg/errors"
)
const keyUser = "user"
func User(ctx context.Context) *model.User {
user, ok := ctx.Value(keyUser).(*model.User)
if !ok {
panic(errors.New("no user in context"))
}
return user
}
func SetUser(ctx context.Context, user *model.User) context.Context {
return context.WithValue(ctx, keyUser, user)
}