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 Permissions
- type PermissonModel
- type Runtime
- type Token
- type TokenModel
- type User
- type UserModel
Constants ¶
View Source
const ( ScopeActivation = "activation" ScopeAuthentication = "authentication" ScopePasswordReset = "password-reset" )
Variables ¶
View Source
var ( ErrRecordNotFound = errors.New("record not found") ErrEditConflict = errors.New("edit conflict") )
View Source
var ( ErrDuplicateEmail = errors.New("duplicate email") AnonymousUser = &User{} )
View Source
var ErrInvalidRuntimeFormat = errors.New("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 Permissons PermissonModel }
type Movie ¶
type Movie struct { ID int64 `json:"id"` // Unique integer ID for the movie CreatedAt time.Time `json:"-"` // Timestamp for when the movie is added to our database Title string `json:"title"` // Movie title Year int32 `json:"year,omitempty"` // Movie release year Runtime Runtime `json:"runtime,omitempty"` // Movie runtime (in minutes) Genres []string `json:"genres,omitempty"` // Slice of genres for the movie (romance, comedy, etc.) Version int32 `json:"version"` // The version number (starts at 1 and increments each time the movie info is updated) }
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
Permissions slice used to hold the permissions codes for a single user.
func (Permissions) Include ¶
func (p Permissions) Include(code string) bool
Include() method checks wether the Permissions slice contains a specific permission code.
type PermissonModel ¶
Define the PermissonsModel type.
func (PermissonModel) AddForUser ¶
func (m PermissonModel) AddForUser(userID int64, codes ...string) error
func (PermissonModel) GetAllForUser ¶
func (m PermissonModel) GetAllForUser(userID int64) (Permissions, error)
The GetAllForUser() method returns all permission codes for a user in a Permissions slice.
type TokenModel ¶
func (TokenModel) DeleteAllForUser ¶
func (m TokenModel) DeleteAllForUser(scope string, userID int64) error
DeleteAllForUser() deletes all tokens for a specific user ans scope.
func (TokenModel) Insert ¶
func (m TokenModel) Insert(token *Token) error
Insert() adds the data for a specific token to the tokens table.
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:"-"` }
func (*User) IsAnonymous ¶
type UserModel ¶
func (UserModel) GetForToken ¶
Click to show internal directories.
Click to hide internal directories.