ots/storage.go

26 lines
461 B
Go
Raw Normal View History

package main
import (
"errors"
"fmt"
"time"
)
2023-10-04 16:53:29 -04:00
var errSecretNotFound = errors.New("secret not found")
type storage interface {
Create(secret string, expireIn time.Duration) (string, error)
ReadAndDestroy(id string) (string, error)
}
func getStorageByType(t string) (storage, error) {
switch t {
case "mem":
return newStorageMem(), nil
case "redis":
return newStorageRedis()
default:
2023-10-04 16:53:29 -04:00
return nil, fmt.Errorf("storage type %q not found", t)
}
}