mirror of
https://github.com/aljazceru/khatru.git
synced 2026-02-23 13:44:24 +01:00
GetConnection() and GetAuthed() may return empty.
This commit is contained in:
12
utils.go
12
utils.go
@@ -22,11 +22,19 @@ func RequestAuth(ctx context.Context) {
|
||||
}
|
||||
|
||||
func GetConnection(ctx context.Context) *WebSocket {
|
||||
return ctx.Value(wsKey).(*WebSocket)
|
||||
wsi := ctx.Value(wsKey)
|
||||
if wsi != nil {
|
||||
return wsi.(*WebSocket)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAuthed(ctx context.Context) string {
|
||||
return GetConnection(ctx).AuthedPublicKey
|
||||
conn := GetConnection(ctx)
|
||||
if conn != nil {
|
||||
return conn.AuthedPublicKey
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetIP(ctx context.Context) string {
|
||||
|
||||
Reference in New Issue
Block a user