Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateEmail(v *validator.Validator, email string)
- func ValidateFilters(v *validator.Validator, f Filters)
- func ValidateMovie(v *validator.Validator, movie *Movie)
- func ValidatePasswordPlaintext(v *validator.Validator, password string)
- func ValidateTokenPlaintext(v *validator.Validator, tokenPlaintext string)
- func ValidateUser(v *validator.Validator, user *User)
- type Filters
- type Metadata
- type Models
- type Movie
- type MovieModel
- type Password
- type Permissions
- type PermissionsModel
- type Runtime
- type Token
- type TokenModel
- type User
- type UserModel
Constants ¶
const ( ScopeActivation = "activation" ScopeAuthentication = "authentication" )
Variables ¶
var ( ErrRecordNotFound = errors.New("record not found") ErrEditConflict = errors.New("edit conflict") )
var AnonymousUser = &User{}
var (
ErrDuplicatedEmail = errors.New("duplicate email")
)
var ErrInvalidRuntimeFormat = fmt.Errorf("invalid runtime format")
Functions ¶
func ValidateEmail ¶
func ValidateFilters ¶
func ValidateMovie ¶
func ValidateTokenPlaintext ¶
func ValidateUser ¶
Types ¶
type Models ¶
type Models struct { Movies MovieModel Users UserModel Tokens TokenModel Permissions PermissionsModel }
type MovieModel ¶
func (MovieModel) Delete ¶
func (m MovieModel) Delete(id int64) error
func (MovieModel) Insert ¶
func (m MovieModel) Insert(movie *Movie) error
func (MovieModel) Update ¶
func (m MovieModel) Update(movie *Movie) error
type Permissions ¶
type Permissions []string
func (Permissions) Include ¶
func (p Permissions) Include(code string) bool
type PermissionsModel ¶
func (PermissionsModel) AddForUser ¶
func (m PermissionsModel) AddForUser(userID int64, codes ...string) error
func (PermissionsModel) GetAllForUser ¶
func (m PermissionsModel) GetAllForUser(userID int64) (Permissions, error)
type Runtime ¶
type Runtime int32
func (Runtime) MarshalJSON ¶
MarshalJSON is a custom JSON marshaler for the Runtime type. This method is called by the json.Marshal() function and it returns the JSON representation of the Runtime type. It needs to be wrapped in double quotes, otherwise it won't be interpreted as a JSON String and we'll receive a runtime error similar to:\n json: error calling MarshalJSON for type data.Runtime: invalid character 'm' after top-level value
func (*Runtime) UnmarshalJSON ¶
Implement a UnmarshalJSON() method on the Runtime type so that it satisfies the json.Unmarshaler interface. IMPORTANT: Because UnmarshalJSON() needs to modify the receiver (our Runtime type), we must use a pointer receiver for this to work correctly. Otherwise, we will only be modifying a copy (which is then discarded when this method returns).
type TokenModel ¶
func (TokenModel) DeleteAllForUser ¶
func (m TokenModel) DeleteAllForUser(userID int64, scope string) error
DeleteAllForUser deletes all tokens for a specific user and scope.
func (TokenModel) Insert ¶
func (m TokenModel) Insert(token *Token) error
type User ¶
type User struct { ID int64 `json:"id"` CreatedAt time.Time `json:"created_at"` Name string `json:"name"` Email string `json:"email"` Password Password `json:"-"` Activated bool `json:"activated"` Version int `json:"-"` }