Documentation ¶
Index ¶
- type Handler
- func (h *Handler) AddComment(c echo.Context) error
- func (h *Handler) Articles(c echo.Context) error
- func (h *Handler) CreateArticle(c echo.Context) error
- func (h *Handler) CurrentUser(c echo.Context) error
- func (h *Handler) DeleteArticle(c echo.Context) error
- func (h *Handler) DeleteComment(c echo.Context) error
- func (h *Handler) Favorite(c echo.Context) error
- func (h *Handler) Feed(c echo.Context) error
- func (h *Handler) Follow(c echo.Context) error
- func (h *Handler) GetArticle(c echo.Context) error
- func (h *Handler) GetComments(c echo.Context) error
- func (h *Handler) GetProfile(c echo.Context) error
- func (h *Handler) Login(c echo.Context) error
- func (h *Handler) Register(v1 *echo.Group)
- func (h *Handler) SignUp(c echo.Context) error
- func (h *Handler) Tags(c echo.Context) error
- func (h *Handler) Unfavorite(c echo.Context) error
- func (h *Handler) Unfollow(c echo.Context) error
- func (h *Handler) UpdateArticle(c echo.Context) error
- func (h *Handler) UpdateUser(c echo.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) AddComment ¶
AddComment godoc @Summary Create a comment for an article @Description Create a comment for an article. Auth is required @ID add-comment @Tags comment @Accept json @Produce json @Param slug path string true "Slug of the article that you want to create a comment for" @Param comment body createCommentRequest true "Comment you want to create" @Success 201 {object} singleCommentResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles/{slug}/comments [post]
func (*Handler) Articles ¶
Articles godoc @Summary Get recent articles globally @Description Get most recent articles globally. Use query parameters to filter results. Auth is optional @ID get-articles @Tags article @Accept json @Produce json @Param tag query string false "Filter by tag" @Param author query string false "Filter by author (username)" @Param favorited query string false "Filter by favorites of a user (username)" @Param limit query integer false "Limit number of articles returned (default is 20)" @Param offset query integer false "Offset/skip number of articles (default is 0)" @Success 200 {object} articleListResponse @Failure 500 {object} utils.Error @Router /articles [get]
func (*Handler) CreateArticle ¶
CreateArticle godoc @Summary Create an article @Description Create an article. Auth is require @ID create-article @Tags article @Accept json @Produce json @Param article body articleCreateRequest true "Article to create" @Success 201 {object} singleArticleResponse @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles [post]
func (*Handler) CurrentUser ¶
CurrentUser godoc @Summary Get the current user @Description Gets the currently logged-in user @ID current-user @Tags user @Accept json @Produce json @Success 200 {object} userResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /user [get]
func (*Handler) DeleteArticle ¶
DeleteArticle godoc @Summary Delete an article @Description Delete an article. Auth is required @ID delete-article @Tags article @Accept json @Produce json @Param slug path string true "Slug of the article to delete" @Success 200 {object} map[string]interface{} @Failure 401 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles/{slug} [delete]
func (*Handler) DeleteComment ¶
DeleteComment godoc @Summary Delete a comment for an article @Description Delete a comment for an article. Auth is required @ID delete-comments @Tags comment @Accept json @Produce json @Param slug path string true "Slug of the article that you want to delete a comment for" @Param id path integer true "ID of the comment you want to delete" @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles/{slug}/comments/{id} [delete]
func (*Handler) Favorite ¶
Favorite godoc @Summary Favorite an article @Description Favorite an article. Auth is required @ID favorite @Tags favorite @Accept json @Produce json @Param slug path string true "Slug of the article that you want to favorite" @Success 200 {object} singleArticleResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles/{slug}/favorite [post]
func (*Handler) Feed ¶
Feed godoc @Summary Get recent articles from users you follow @Description Get most recent articles from users you follow. Use query parameters to limit. Auth is required @ID feed @Tags article @Accept json @Produce json @Param limit query integer false "Limit number of articles returned (default is 20)" @Param offset query integer false "Offset/skip number of articles (default is 0)" @Success 200 {object} articleListResponse @Failure 401 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles/feed [get]
func (*Handler) Follow ¶
Follow godoc @Summary Follow a user @Description Follow a user by username @ID follow @Tags follow @Accept json @Produce json @Param username path string true "Username of the profile you want to follow" @Success 200 {object} profileResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /profiles/{username}/follow [post]
func (*Handler) GetArticle ¶
GetArticle godoc @Summary Get an article @Description Get an article. Auth not required @ID get-article @Tags article @Accept json @Produce json @Param slug path string true "Slug of the article to get" @Success 200 {object} singleArticleResponse @Failure 400 {object} utils.Error @Failure 500 {object} utils.Error @Router /articles/{slug} [get]
func (*Handler) GetComments ¶
GetComments godoc @Summary Get the comments for an article @Description Get the comments for an article. Auth is optional @ID get-comments @Tags comment @Accept json @Produce json @Param slug path string true "Slug of the article that you want to get comments for" @Success 200 {object} commentListResponse @Failure 422 {object} utils.Error @Failure 500 {object} utils.Error @Router /articles/{slug}/comments [get]
func (*Handler) GetProfile ¶
GetProfile godoc @Summary Get a profile @Description Get a profile of a user of the system. Auth is optional @ID get-profile @Tags profile @Accept json @Produce json @Param username path string true "Username of the profile to get" @Success 200 {object} userResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /profiles/{username} [get]
func (*Handler) Login ¶
Login godoc @Summary Login for existing user @Description Login for existing user @ID login @Tags user @Accept json @Produce json @Param user body userLoginRequest true "Credentials to use" @Success 200 {object} userResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Router /users/login [post]
func (*Handler) SignUp ¶
SignUp godoc @Summary Register a new user @Description Register a new user @ID sign-up @Tags user @Accept json @Produce json @Param user body userRegisterRequest true "User info for registration" @Success 201 {object} userResponse @Failure 400 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Router /users [post]
func (*Handler) Tags ¶
Tags godoc @Summary Get tags @Description Get tags @ID tags @Tags tag @Accept json @Produce json @Success 201 {object} tagListResponse @Failure 400 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /tags [get]
func (*Handler) Unfavorite ¶
Unfavorite godoc @Summary Unfavorite an article @Description Unfavorite an article. Auth is required @ID unfavorite @Tags favorite @Accept json @Produce json @Param slug path string true "Slug of the article that you want to unfavorite" @Success 200 {object} singleArticleResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles/{slug}/favorite [delete]
func (*Handler) Unfollow ¶
Unfollow godoc @Summary Unfollow a user @Description Unfollow a user by username @ID unfollow @Tags follow @Accept json @Produce json @Param username path string true "Username of the profile you want to unfollow" @Success 201 {object} userResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /profiles/{username}/follow [delete]
func (*Handler) UpdateArticle ¶
UpdateArticle godoc @Summary Update an article @Description Update an article. Auth is required @ID update-article @Tags article @Accept json @Produce json @Param slug path string true "Slug of the article to update" @Param article body articleUpdateRequest true "Article to update" @Success 200 {object} singleArticleResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /articles/{slug} [put]
func (*Handler) UpdateUser ¶
UpdateUser godoc @Summary Update current user @Description Update user information for current user @ID update-user @Tags user @Accept json @Produce json @Param user body userUpdateRequest true "User details to update. At least **one** field is required." @Success 200 {object} userResponse @Failure 400 {object} utils.Error @Failure 401 {object} utils.Error @Failure 422 {object} utils.Error @Failure 404 {object} utils.Error @Failure 500 {object} utils.Error @Security ApiKeyAuth @Router /user [put]