handler

package
v0.0.0-...-87fd83c Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

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 NewHandler

func NewHandler(us user.Store, as article.Store) *Handler

func (*Handler) AddComment

func (h *Handler) AddComment(c echo.Context) error

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

func (h *Handler) Articles(c echo.Context) error

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

func (h *Handler) CreateArticle(c echo.Context) error

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

func (h *Handler) CurrentUser(c echo.Context) error

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

func (h *Handler) DeleteArticle(c echo.Context) error

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

func (h *Handler) DeleteComment(c echo.Context) error

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

func (h *Handler) Favorite(c echo.Context) error

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

func (h *Handler) Feed(c echo.Context) error

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

func (h *Handler) Follow(c echo.Context) error

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

func (h *Handler) GetArticle(c echo.Context) error

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

func (h *Handler) GetComments(c echo.Context) error

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

func (h *Handler) GetProfile(c echo.Context) error

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

func (h *Handler) Login(c echo.Context) error

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) Register

func (h *Handler) Register(v1 *echo.Group)

func (*Handler) SignUp

func (h *Handler) SignUp(c echo.Context) error

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

func (h *Handler) Tags(c echo.Context) error

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

func (h *Handler) Unfavorite(c echo.Context) error

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

func (h *Handler) Unfollow(c echo.Context) error

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

func (h *Handler) UpdateArticle(c echo.Context) error

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

func (h *Handler) UpdateUser(c echo.Context) error

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]

Jump to

Keyboard shortcuts

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