v1

package
v0.0.0-...-3beaeaf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticleHandler

type ArticleHandler struct {
	// contains filtered or unexported fields
}

func NewArticleHandler

func NewArticleHandler(svc ArticleService) *ArticleHandler

func (*ArticleHandler) HandleCreateArticle

func (h *ArticleHandler) HandleCreateArticle(w http.ResponseWriter, r *http.Request)

HandleCreateArticle godoc @Summary Create an article @Tags articles @Produce json @Param request body request.CreateArticleRequest true "request body" @Success 200 {object} domain.Article @Failure 400 {object} response.Err @Failure 500 {object} response.Err @Router /articles [post]

func (*ArticleHandler) HandleGetArticle

func (h *ArticleHandler) HandleGetArticle(w http.ResponseWriter, r *http.Request)

HandleGetArticle godoc @Summary Get an article @Tags articles @Produce json @Param articleID path int true "article ID" @Success 200 {object} domain.Article @Failure 400 {object} response.Err @Failure 404 {object} response.Err @Failure 500 {object} response.Err @Router /articles/{articleID} [get]

func (*ArticleHandler) HandleListArticles

func (h *ArticleHandler) HandleListArticles(w http.ResponseWriter, r *http.Request)

HandleListArticles godoc @Summary List all articles @Tags articles @Produce json @Param page query int false "which page to load. Default to 1 if empty." @Param per_page query int false "how many items per page. Default to 10 if empty." @Success 200 {object} []domain.Article @Failure 500 {object} response.Err @Router /articles [get]

func (*ArticleHandler) HandleSearchArticles

func (h *ArticleHandler) HandleSearchArticles(w http.ResponseWriter, r *http.Request)

HandleSearchArticles godoc @Summary Search articles @Tags articles @Produce json @Param title query string false "search by title" @Param content query string false "search by content" @Success 200 {object} []domain.Article @Failure 500 {object} response.Err @Router /articles/search [get]

type ArticleService

type ArticleService interface {
	CreateArticle(ctx context.Context, article domain.Article) (domain.Article, error)
	GetArticle(ctx context.Context, id uint) (domain.Article, error)
	ListArticles(ctx context.Context, page uint, perPage uint) ([]domain.Article, error)
	SearchArticles(ctx context.Context, title, content string) ([]domain.Article, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL