Documentation ¶
Index ¶
- func Delete(key string) error
- func Get(key string, obj any) error
- func Init(cfg any) error
- func KeyFromEnv() (*rsa.PrivateKey, error)
- func KeyFromTTY() (*rsa.PrivateKey, error)
- func Marshal(v interface{}) ([]byte, error)
- func New(t BackendType, cfg any, key *rsa.PrivateKey) error
- func ReadKey(path *string, remove bool) (*rsa.PrivateKey, error)
- func Set(key string, value any) error
- func Unmarshal(data []byte, v interface{}) error
- type Backend
- type BackendType
- type FileBackend
- type MemoryBackend
- type RedisBackend
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyFromEnv ¶
func KeyFromEnv() (*rsa.PrivateKey, error)
func KeyFromTTY ¶
func KeyFromTTY() (*rsa.PrivateKey, error)
func New ¶
func New(t BackendType, cfg any, key *rsa.PrivateKey) error
func ReadKey ¶
func ReadKey(path *string, remove bool) (*rsa.PrivateKey, error)
ReadKey will read a private key, parse it, and return a *rsa.PrivateKey If path is provided, the key will be read from the file at that path If a MEMORY_KEY environment variable is set, the key will be read from that If path is nil and MEMORY_KEY is not set, the user will be prompted to enter a key If remove is true, the file at path will be removed after reading
Types ¶
type Backend ¶
type Backend interface { Init(cfg any) error Get(key string) ([]byte, error) Set(key string, value []byte) error Delete(key string) error }
var ( B Backend Key *rsa.PrivateKey )
type BackendType ¶
type BackendType string
const ( MemoryBackendType BackendType = "memory" MemoryBackendRedis BackendType = "redis" MemoryBackendFile BackendType = "file" )
type FileBackend ¶
type FileBackend struct {
Dir string `json:"dir"`
}
func (*FileBackend) Delete ¶
func (b *FileBackend) Delete(key string) error
func (*FileBackend) Init ¶
func (b *FileBackend) Init(cfg any) error
type MemoryBackend ¶
func (*MemoryBackend) Delete ¶
func (m *MemoryBackend) Delete(key string) error
func (*MemoryBackend) Init ¶
func (m *MemoryBackend) Init(cfg any) error
type RedisBackend ¶
type RedisBackend struct { Host string `json:"host"` Port int `json:"port"` Password string `json:"password"` Db int `json:"db"` TlsCa string `json:"tls_ca"` TlsCert string `json:"tls_cert"` TlsKey string `json:"tls_key"` // contains filtered or unexported fields }
func (*RedisBackend) Delete ¶
func (m *RedisBackend) Delete(key string) error
func (*RedisBackend) Init ¶
func (m *RedisBackend) Init(cfg any) error
Click to show internal directories.
Click to hide internal directories.