get raw data from storage or memory
(ctx context.Context, key string)
| 34 | |
| 35 | // get raw data from storage or memory |
| 36 | func (m *storageManager) getRaw(ctx context.Context, key string) ([]byte, error) { |
| 37 | if m.storage != nil { |
| 38 | raw, err := m.storage.GetWithContext(ctx, key) |
| 39 | if err != nil { |
| 40 | return nil, fmt.Errorf("csrf: failed to get value from storage: %w", err) |
| 41 | } |
| 42 | return raw, nil |
| 43 | } |
| 44 | |
| 45 | if value := m.memory.Get(key); value != nil { |
| 46 | raw, ok := value.([]byte) |
| 47 | if !ok { |
| 48 | return nil, fmt.Errorf("csrf: unexpected value type %T in storage", value) |
| 49 | } |
| 50 | return raw, nil |
| 51 | } |
| 52 | |
| 53 | return nil, nil |
| 54 | } |
| 55 | |
| 56 | // set data to storage or memory |
| 57 | func (m *storageManager) setRaw(ctx context.Context, key string, raw []byte, exp time.Duration) error { |