Documentation ¶
Index ¶
- func Init(fn AclDSFactory, d IDataSource) (err error)
- func PatchReceiver() interface{}
- func QOFactory(c *gin.Context, d IDataSource) (*QueryOptions, *TagError)
- func UID(c *gin.Context) string
- func Values(d IDataSource) map[string]interface{}
- type Acl
- type AclDSFactory
- type DuplicatedEntry
- type ExpiredCredentials
- type ExpiredPinError
- type ForeignKeyConstraint
- type Grant
- type IAclDataSource
- type IDataSource
- type IPinDataSource
- type IUserDataSource
- type InsertError
- 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 UpdateError
- type User
- type UserDSFactory
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(fn AclDSFactory, d IDataSource) (err error)
Meant to be executed on startup, Init loads the acl map in memory. acl maps each grant to a time range. Helps speed up Authorization middleware.
func PatchReceiver ¶
func PatchReceiver() interface{}
func QOFactory ¶
func QOFactory(c *gin.Context, d IDataSource) (*QueryOptions, *TagError)
QueryOptsFactory exported
func Values ¶ added in v0.2.12
func Values(d IDataSource) map[string]interface{}
Types ¶
type AclDSFactory ¶
type AclDSFactory func(dsrc IDataSource) (IAclDataSource, error)
AclDSFactory makes a IAclDataSource from a generic dsrc IDataSource.
type DuplicatedEntry ¶ added in v0.2.14
DuplicatedEntry exported
type ExpiredCredentials ¶
ExpiredCredentials exported
type ForeignKeyConstraint ¶ added in v0.2.10
ForeignKeyConstraint exported
type Grant ¶
type Grant struct { Role string `json:"role"` Route string `json:"route"` Method string `json:"method"` }
Grant exported
type IAclDataSource ¶ added in v0.2.10
type IAclDataSource interface { // Returns all grants mapped to its corresponding validity time range. Fetch() (Acl, error) }
Defines an interface for ACL data access.
type IDataSource ¶ added in v0.2.10
type IDataSource interface { // Must return ds name. // i.e. For a db store this is the table name Name() string Count(qo *QueryOptions) (int64, error) Find(qo *QueryOptions) (ResultSetMeta, interface{}, error) Fetch(qo *QueryOptions) (ResultSetMeta, []interface{}, error) Insert(qo *QueryOptions) error Update(qo *QueryOptions) (int64, error) Delete(qo *QueryOptions) (int64, error) }
IDataSource defines an interface for resource data access.
type IPinDataSource ¶ added in v0.2.10
type IPinDataSource interface { // Post Pin Post(email string) (Pin, error) // Patch password PatchPwd(patch *Patch, crypto lib.ICrypto) error }
IPinDataSource defines an interface to post pins and patch passwords using a pin.
type IUserDataSource ¶ added in v0.2.10
type IUserDataSource 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 IDataSource) (IPinDataSource, error)
AclDSFactory makes a IPinDataSource from generic p(pin) and u(user) IDataSource's.
type QueryOptions ¶
type QueryOptions struct { User User DataSource IDataSource Fields []string WritableFields []string 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(dsrc IDataSource, params Params) *QueryOptions
type ResultSetMeta ¶
type TagError ¶
TagError exported
func Meta ¶ added in v0.2.11
func Meta(d IDataSource) (k, f, w []string, e *TagError)
func TagValuesPivoted ¶
func TagValuesPivoted(dsrc IDataSource, 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(dsrc IDataSource) (IUserDataSource, error)
UserDSFactory makes a IUserDataSource from a generic dsrc IDataSource.
type ValidationErrors ¶ added in v0.2.15
type ValidationErrors msg.MessageList
TagError exported
func (*ValidationErrors) Error ¶ added in v0.2.15
func (ve *ValidationErrors) Error() string
Error exported