tools.go
1package tools
2
3import (
4 "context"
5)
6
7type (
8 sessionIDContextKey string
9 messageIDContextKey string
10)
11
12const (
13 SessionIDContextKey sessionIDContextKey = "session_id"
14)
15
16func GetSessionFromContext(ctx context.Context) string {
17 sessionID := ctx.Value(SessionIDContextKey)
18 if sessionID == nil {
19 return ""
20 }
21 s, ok := sessionID.(string)
22 if !ok {
23 return ""
24 }
25 return s
26}