Documentation
¶
Index ¶
- type Article
- type CreateInput
- type Handlers
- type News
- type Service
- func (s *Service) Create(ctx context.Context, in CreateInput, image *upload.File) (Article, error)
- func (s *Service) Delete(ctx context.Context, id int) (Article, error)
- func (s *Service) Get(ctx context.Context, id int) (Article, error)
- func (s *Service) Latest(ctx context.Context) (Article, bool, error)
- func (s *Service) List(ctx context.Context) ([]Article, error)
- func (s *Service) Update(ctx context.Context, id int, in UpdateInput, image *upload.File) (Article, error)
- type Store
- func (s *Store) AddNews(ctx context.Context, newsParam News) (News, error)
- func (s *Store) DeleteNews(ctx context.Context, newsParam News) error
- func (s *Store) EditNews(ctx context.Context, newsParam News) (News, error)
- func (s *Store) GetNews(ctx context.Context) ([]News, error)
- func (s *Store) GetNewsArticle(ctx context.Context, newsParam News) (News, error)
- func (s *Store) GetNewsLatest(ctx context.Context) (News, error)
- type UpdateInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct {
ID int `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Date time.Time `json:"date"`
ImageURL string `json:"imageUrl,omitempty"`
}
Article is a news article as the API returns it.
type CreateInput ¶
CreateInput is a new article. Content is HTML from the editor and is sanitised.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
Handlers serves /news.
func NewHandlers ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the news business logic.
func NewService ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store stores the dependencies
func (*Store) EditNews ¶
EditNews writes n as given. Callers load the row first and change only the fields they mean to, so empty values are deliberate (e.g. removing an image).
func (*Store) GetNewsArticle ¶
type UpdateInput ¶
UpdateInput changes an article. Nil fields are left unchanged; an empty Content clears it. RemoveImage is ignored when a new image is uploaded.
Click to show internal directories.
Click to hide internal directories.