16 lines
299 B
Go
16 lines
299 B
Go
package graph
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// getUserIDFromContext извлекает userID из контекста
|
|
func getUserIDFromContext(ctx context.Context) (int, error) {
|
|
userID, ok := ctx.Value("userID").(int)
|
|
if !ok {
|
|
return 0, errors.New("unauthorized")
|
|
}
|
|
return userID, nil
|
|
}
|