Documentation
¶
Index ¶
- Constants
- type ArticleRequest
- type CreateRequest
- type ProfilesStore
- type ResponseMulti
- type ResponseSingle
- type Server
- func (s *Server) HandleCreate(w http.ResponseWriter, r *http.Request) error
- func (s *Server) HandleDelete(w http.ResponseWriter, r *http.Request) error
- func (s *Server) HandleFeed(w http.ResponseWriter, r *http.Request) error
- func (s *Server) HandleGet(w http.ResponseWriter, r *http.Request) error
- func (s *Server) HandleList(w http.ResponseWriter, r *http.Request) error
- func (s *Server) HandleUpdate(w http.ResponseWriter, r *http.Request) error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Service
- func (s *Service) Create(req *CreateRequest, author *app.Profile) (*app.Article, error)
- func (s *Service) Delete(slug string, author *app.Profile) error
- func (s *Service) Get(slug string) (*app.Article, error)
- func (s *Service) List(filter *app.ArticleListFilter) ([]*app.Article, error)
- func (s *Service) Update(slug string, author *app.Profile, req *UpdateRequest) (*app.Article, error)
- type Store
- type UpdateArticle
- type UpdateRequest
Constants ¶
View Source
const (
// Length of random string appended to slug to make it unique
SlugRandLen = 4
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArticleRequest ¶
type CreateRequest ¶
type CreateRequest struct {
Article ArticleRequest `json:"article"`
}
func (*CreateRequest) Validate ¶
func (r *CreateRequest) Validate() error
type ProfilesStore ¶
type ProfilesStore interface {
GetProfile(username string, follower *app.Profile) (*app.Profile, error)
}
ProfilesStore provides helper to get author with all its fields (like id) by username
type ResponseMulti ¶
type ResponseSingle ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewHTTP ¶
func NewHTTP(store Store, profilesStore ProfilesStore, secret []byte) (*Server, error)
func (*Server) HandleCreate ¶
func (*Server) HandleDelete ¶
func (*Server) HandleFeed ¶
func (*Server) HandleList ¶
func (*Server) HandleUpdate ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides methods for articles
func NewService ¶
func NewService(store Store, profileStore ProfilesStore) *Service
NewService creates new instance of the service with provided store
type Store ¶
type Store interface { CreateArticle(a *app.Article) error GetArticle(slug string) (*app.Article, error) ListArticles(f *app.ArticleListFilter) ([]*app.Article, error) UpdateArticle(a *app.Article) error DeleteArticle(id int) error }
ArticleStore defines an interface to work with articles
type UpdateArticle ¶
type UpdateRequest ¶
type UpdateRequest struct {
Article UpdateArticle `json:"article"`
}
func (*UpdateRequest) Validate ¶
func (r *UpdateRequest) Validate() error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.