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 MockMovieModel
- func (m MockMovieModel) Delete(id int64) error
- func (m MockMovieModel) Get(id int64) (*Movie, error)
- func (m MockMovieModel) GetAll(title string, genres []string, filters Filters) ([]*Movie, Metadata, error)
- func (m MockMovieModel) Insert(movie *Movie) error
- func (m MockMovieModel) Update(movie *Movie) error
- type MockTokenModel
- type MockUserModel
- type Models
- type Movie
- type MovieModel
- type PermissionModel
- type Permissions
- type Runtime
- type Token
- type TokenModel
- type User
- type UserModel
Constants ¶
View Source
const ( ScopeActivation = "activation" ScopeAuthentication = "authentication" )
Variables ¶
View Source
var ( ErrRecordNotFound = errors.New("record not found") ErrEditConflict = errors.New("edit conflict") )
View Source
var AnonymousUser = &User{}
View Source
var ErrDuplicateEmail = errors.New("duplicate email")
View Source
var ErrInvalidRuntimeFormat = errors.New("invalid runtime format")
Functions ¶
func ValidateEmail ¶
func ValidateFilters ¶
func ValidateMovie ¶
func ValidateTokenPlaintext ¶
func ValidateUser ¶
Types ¶
type MockMovieModel ¶
type MockMovieModel struct{}
func (MockMovieModel) Delete ¶
func (m MockMovieModel) Delete(id int64) error
func (MockMovieModel) Insert ¶
func (m MockMovieModel) Insert(movie *Movie) error
func (MockMovieModel) Update ¶
func (m MockMovieModel) Update(movie *Movie) error
type MockTokenModel ¶
type MockTokenModel struct{}
func (MockTokenModel) DeleteAllForUser ¶
func (m MockTokenModel) DeleteAllForUser(scope string, userID int64) error
func (MockTokenModel) Insert ¶
func (m MockTokenModel) Insert(token *Token) error
type MockUserModel ¶
type MockUserModel struct{}
func (MockUserModel) GetByEmail ¶
func (m MockUserModel) GetByEmail(email string) (*User, error)
func (MockUserModel) GetForToken ¶
func (m MockUserModel) GetForToken(tokenScope, tokenPlaintext string) (*User, error)
func (MockUserModel) Insert ¶
func (m MockUserModel) Insert(user *User) error
func (MockUserModel) Update ¶
func (m MockUserModel) Update(user *User) error
type Models ¶
type Models struct { Movies interface { Get(id int64) (*Movie, error) Insert(movie *Movie) error Update(movie *Movie) error Delete(id int64) error GetAll(title string, genres []string, filters Filters) ([]*Movie, Metadata, error) } Users interface { GetByEmail(email string) (*User, error) Insert(user *User) error Update(user *User) error GetForToken(tokenScope, tokenPlaintext string) (*User, error) } Tokens interface { New(userID int64, ttl time.Duration, scope string) (*Token, error) Insert(token *Token) error DeleteAllForUser(scope string, userID int64) error } Permissions interface { GetAllForUser(userID int64) (Permissions, error) AddForUser(userID int64, codes ...string) error } }
func NewMockModels ¶
func NewMockModels() Models
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 PermissionModel ¶
func (PermissionModel) AddForUser ¶
func (m PermissionModel) AddForUser(userID int64, codes ...string) error
func (PermissionModel) GetAllForUser ¶
func (m PermissionModel) GetAllForUser(userID int64) (Permissions, error)
type Permissions ¶
type Permissions []string
func (Permissions) Include ¶
func (p Permissions) Include(code string) bool
type TokenModel ¶
func (TokenModel) DeleteAllForUser ¶
func (m TokenModel) DeleteAllForUser(scope string, userID int64) error
func (TokenModel) Insert ¶
func (m TokenModel) Insert(token *Token) error
type User ¶
type User struct { ID int64 `json:"id"` Name string `json:"name"` Email string `json:"email"` Password password `json:"-"` Activated bool `json:"activated"` CreatedAt time.Time `json:"created_at"` Version int `json:"-"` }
func (*User) IsAnonymous ¶
type UserModel ¶
func (UserModel) GetForToken ¶
Click to show internal directories.
Click to hide internal directories.