Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorCode(err error) string
- func InternalError(err error) error
- type Article
- type ArticleRepo
- type ArticleService
- type Bio
- type Comment
- type Comments
- type Error
- type Favorites
- type FeedRequest
- type FollowRequest
- type Follows
- type Image
- type ListRequest
- type Tag
- type Tags
- type User
- type UserRepo
- type UserService
Constants ¶
View Source
const ( // Action cannot be performed. EConflict = "conflict" // Internal error. EInternal = "internal" // Entity does not exist. ENotFound = "not_found" // Too many API requests. ERateLimit = "rate_limit" // User ID validation failed. EInvalidUserID = "invalid_user_id" // Username validation failed. EInvalidUsername = "invalid_username" EIncorrectPassword = "incorrect_password" )
Application error codes.
Variables ¶
View Source
var ( ErrArticleNotFound = Error{ENotFound, errors.New("article not found")} ErrArticleAlreadyExists = Error{EConflict, errors.New("article already exists")} )
View Source
var ( ErrResourceNotFound = Error{ENotFound, errors.New("resource not found")} ErrUserNotFound = Error{ENotFound, errors.New("user not found")} ErrUserAlreadyExists = Error{EConflict, errors.New("user already exists")} ErrIncorrectPasswordError = Error{EIncorrectPassword, errors.New("incorrect password")} )
Functions ¶
func InternalError ¶
Types ¶
type Article ¶
type ArticleRepo ¶
type ArticleRepo interface { Get(slug string) (*Article, error) List(offset, limit int) ([]*Article, int, error) ListByTag(tag string, offset, limit int) ([]*Article, int, error) ListByAuthorID(id int64, offset, limit int) ([]*Article, int, error) ListByFavoriterID(id int64, offset, limit int) ([]*Article, int, error) Feed(req FeedRequest) ([]*Article, int, error) Create(u Article) (*Article, error) Update(slug string, u Article) (*Article, error) Delete(u Article) error AddFavorite(a Article, u User) (*Article, error) RemoveFavorite(a Article, u User) (*Article, error) AddComment(c Comment) (*Comment, error) DeleteComment(c Comment) error Comments(a Article) ([]*Comment, error) Tags() ([]*Tag, error) }
type ArticleService ¶
type ArticleService interface { Create(a Article) (*Article, error) Update(slug string, a Article) (*Article, error) Get(a Article) (*Article, error) List(r ListRequest) ([]*Article, int, error) Feed(r FeedRequest) ([]*Article, int, error) Delete(a Article) error Favorite(a Article, u User) (*Article, error) Unfavorite(a Article, u User) (*Article, error) AddComment(c Comment) (*Comment, error) DeleteComment(c Comment) error Comments(a Article) ([]*Comment, error) Tags() ([]*Tag, error) }
type FeedRequest ¶
type FollowRequest ¶
type Image ¶
func (Image) MarshalJSON ¶
func (*Image) UnmarshalJSON ¶
TODO: check: if we can extract these methods to a generic methods/type and attach these to the type
type ListRequest ¶
type User ¶
type User struct { ID int64 Username string Email string Password string Bio Bio Image Image Followers Follows Followings Follows }
TODO: where should we put the validation? Should we have separate validation per domain model and transports?
func (*User) CheckPassword ¶
func (*User) IsFollower ¶
type UserRepo ¶
type UserRepo interface { // TODO: should this return user? What if we assume this should only be a **write** command Create(u User) (*User, error) Update(u User) (*User, error) Get(e string) (*User, error) GetByID(id int64) (*User, error) GetByUsername(u string) (*User, error) AddFollower(follower, followee int64) (*User, error) RemoveFollower(follower, followee int64) (*User, error) }
type UserService ¶
Click to show internal directories.
Click to hide internal directories.