init repo
This commit is contained in:
21
common/context.go
Normal file
21
common/context.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nose7en/ToyBoomServer/defs"
|
||||
)
|
||||
|
||||
func GetUser(c context.Context) defs.UserGettable {
|
||||
val := c.Value(UserInfoKey)
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
u, ok := val.(defs.UserGettable)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
return u
|
||||
}
|
||||
Reference in New Issue
Block a user