diff options
Diffstat (limited to 'contextlib/user.go')
-rw-r--r-- | contextlib/user.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/contextlib/user.go b/contextlib/user.go new file mode 100644 index 0000000..6ef12d6 --- /dev/null +++ b/contextlib/user.go @@ -0,0 +1,21 @@ +package contextlib + +import ( + "context" + + "gitrepo.ru/neonxp/gorum/models" +) + +func GetUser(ctx context.Context) *models.User { + u := ctx.Value(UserKey) + if u == nil { + return nil + } + + user, ok := u.(models.User) + if !ok { + return nil + } + + return &user +} |