Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRoutes ¶
func NewRoutes(c Controller) router.Router
NewRoutes creates a router for Article and sets the endpoints
Types ¶
type Article ¶
type Article struct { ID uint `json:"id" gorm:"primary_key"` Title string `json:"title"` Content string `json:"content"` Author string `json:"author"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"deleted_at,omitempty" sql:"index"` }
Article represents the article entity's attributes.
type Controller ¶
type Controller interface { // Create requests the received article to be stored Create(a *Article) error // List returns all the stored articles List() (*[]Article, error) }
Controller defines the methods to be exposed in Controller layer
func NewController ¶
func NewController(r Repository) Controller
NewController creates a new Controller with access to Repository methods
type MockController ¶
MockController injects mock dependency into controller
func (*MockController) Create ¶
func (m *MockController) Create(article *Article) error
Create represents the mocked method for Create feature in Controller layer
func (*MockController) List ¶
func (m *MockController) List() (*[]Article, error)
List represents the mocked method for List feature in Controller layer
type MockRepository ¶
MockRepository injects mock dependency into repository
func (*MockRepository) Create ¶
func (m *MockRepository) Create(article *Article) error
Create represents the mocked method for Create feature in Repository layer
func (*MockRepository) List ¶
func (m *MockRepository) List() (*[]Article, error)
List represents the mocked method for List feature in Repository layer
type Repository ¶
type Repository interface { // Create inserts the article into the database Create(a *Article) error // List selects all articles from database List() (*[]Article, error) }
Repository defines the methods to be exposed in Repository layer
func NewRepository ¶
func NewRepository(db database.Driver) Repository
NewRepository creates a new Repository with access to database