Documentation
¶
Index ¶
- func Init(fn AclDSFactory, d IDataStore) (err error)
- func PatchReceiver() interface{}
- func QOFactory(c *gin.Context, d IDataStore) (*QueryOptions, *TagError)
- func UID(c *gin.Context) string
- type Acl
- type AclDSFactory
- type ExpiredCredentials
- type ExpiredPinError
- type Grant
- type IAclDataStore
- type IDataStore
- type IPinDataStore
- type IUserDataStore
- type InvalidCredentials
- type InvalidPinError
- type NotAllowedError
- type NotFoundError
- type ParamType
- type Params
- type Patch
- type Pin
- type PinDSFactory
- type QueryOptions
- type ResultSetMeta
- type TagError
- type TimeRange
- type User
- type UserDSFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(fn AclDSFactory, d IDataStore) (err error)
Meant to be executed on startup, Init loads the acl map in memory.
func PatchReceiver ¶
func PatchReceiver() interface{}
func QOFactory ¶
func QOFactory(c *gin.Context, d IDataStore) (*QueryOptions, *TagError)
QueryOptsFactory exported
Types ¶
type AclDSFactory ¶
type AclDSFactory func(dst IDataStore) (IAclDataStore, error)
AclDSFactory makes a IAclDataStore from a generic dst IDataStore.
type ExpiredCredentials ¶
ExpiredCredentials exported
type Grant ¶
type Grant struct { Role string `json:"role"` Route string `json:"route"` Method string `json:"method"` }
Grant exported
type IAclDataStore ¶
type IAclDataStore interface { // Returns all grants mapped to its corresponding validity time range. Fetch() (Acl, error) }
Defines an interface for ACL data access.
type IDataStore ¶
type IDataStore interface { // Must return ds name. // i.e. For a db store this is the table name Name() string Find(qo *QueryOptions) (ResultSetMeta, interface{}, error) Fetch(qo *QueryOptions) (ResultSetMeta, []interface{}, error) Insert(qo *QueryOptions) error Delete(qo *QueryOptions) (int64, error) }
Interface defines an interface for resource data access.
type IPinDataStore ¶
type IPinDataStore interface { // Post Pin Post(email string) (Pin, error) // Patch password PatchPwd(patch *Patch) error }
IPinDataStore defines an interface to post pins and patch passwords using a pin.
type IUserDataStore ¶
type IUserDataStore interface { // Return the active User matching the username Get(username string) (User, error) }
Defines an interface to retrieve user data and modify password.
type InvalidCredentials ¶
InvalidCredentials exported
type Patch ¶
type Patch struct { Pin string `json:"pin"` Email string `json:"usr"` Password string `json:"pwd"` }
func PatchDecoder ¶
type Pin ¶
type PinDSFactory ¶
type PinDSFactory func(p, u IDataStore) (IPinDataStore, error)
AclDSFactory makes a IPinDataStore from generic p(pin) and u(user) IDataStore's.
type QueryOptions ¶
type QueryOptions struct { User User DataStore IDataStore Fields []string WritableFields []string WritableValues []interface{} Checksum int Dig []string Equal map[ParamType]Params IsNull []string IsNotNull []string In map[string][]interface{} NotIn map[string][]interface{} NotEqual Params GreaterThan Params LessThan Params GreaterEqualThan Params LessEqualThan Params Order []string Offset int Limit *int }
QueryOpts exported
func (*QueryOptions) Copy ¶
func (qo *QueryOptions) Copy(dst IDataStore, params Params) *QueryOptions
type ResultSetMeta ¶
type TagError ¶
TagError exported
func TagValuesPivoted ¶
func TagValuesPivoted(dst IDataStore, targetTagKey string, pivotTagKey string, pivotTagValues []string) ([]string, *TagError)
Works on structs with two tag sets, let's call them target and pivot.
Returns a slice with the target tag's values, provided the pivot tag name and values are matched.
model is the struct to work with.
tagName is the target tag name.
pivotTagName is the pivot tag name to be matched.
pivotTagFields are the pivot tag values to be matched.
Example:
type User struct { UserID int64 `db:"user_id" auth:"id" json:"user_id" pk:"1"` RoleID *int64 `db:"role_id" auth:"role" json:"role_id"` Email string `db:"email" auth:"usr" json:"email"` }
fields, _ := TagFieldsPivoted(new(User), "auth", []string{"id","role","usr"}) fields -> []string{"user_id","role_id","email"}
type User ¶
type User struct { UID string `json:"uid"` Usr string `json:"usr"` Pwd string `json:"pwd"` Type string `json:"type"` Role string `json:"role"` TPS float32 `json:"tps"` From time.Time `json:"from"` To time.Time `json:"to"` }
User exported
type UserDSFactory ¶
type UserDSFactory func(dst IDataStore) (IUserDataStore, error)
UserDSFactory makes a IUserDataStore from a generic dst IDataStore.