37 lines
466 B
Go
37 lines
466 B
Go
package urbac
|
|
|
|
import (
|
|
"github.com/loveuer/urbac/cache"
|
|
"github.com/loveuer/urbac/store"
|
|
)
|
|
|
|
type Urbac struct {
|
|
cache cache.Cache
|
|
store store.Store
|
|
}
|
|
|
|
type Option func(u *Urbac)
|
|
|
|
func New(opts ...Option) (*Urbac, error) {
|
|
var (
|
|
err error
|
|
u = &Urbac{}
|
|
)
|
|
|
|
for _, opt := range opts {
|
|
opt(u)
|
|
}
|
|
|
|
if u.store == nil {
|
|
if u.store, err = store.NewSqliteStore(":memory:"); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
if u.cache == nil {
|
|
|
|
}
|
|
|
|
return u, nil
|
|
}
|