handler

package
v0.0.0-...-4a9023c Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 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 DataList

type DataList struct {
	ID       uint   `json:"id"`
	Title    string `json:"title"`
	Content  string `json:"content"`
	Author   string `json:"author"`
	Creator  uint   `json:"creator"`
	Modifier uint   `json:"modifier"`
	User     struct {
		ID        uint
		CreatedAt time.Time
		UpdatedAt time.Time
	} `json:"user"`
}

type Handler

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

func NewHandler

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

func (*Handler) Article

func (h *Handler) Article(c *fiber.Ctx) error

Article godoc @Summary Get all articles with Limit and Offset. @Description Get most recent article globally. Auth is optional @ID get-article @Tags article @Accept json @Produce json @Param limit path int true "Limit number of articles returned (default is 20)" @Param offset path int true "Offset/skip number of articles (default is 0)" @Success 200 {object} articleDataListResponse @Failure 500 {object} utils.Error @Router /articles/{limit}/{offset} [get]

func (*Handler) ArticleList

func (h *Handler) ArticleList(c *fiber.Ctx) error

ArticleList godoc @Summary Get all articles @Description Get article list. Auth not required @ID get-article-lists @Tags article @Accept json @Produce json @Success 200 {object} articleDataListResponse @Failure 400 {object} utils.Error @Failure 500 {object} utils.Error @Router /articles/list [get]

func (*Handler) CreateArticle

func (h *Handler) CreateArticle(c *fiber.Ctx) 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 *fiber.Ctx) 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 *fiber.Ctx) error

DeleteArticle godoc @Summary Delete an article @Description Delete an article. Auth is required @ID delete-article @Tags article @Accept json @Produce json @Param id path int true "ID 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/{id} [delete]

func (*Handler) GetArticle

func (h *Handler) GetArticle(c *fiber.Ctx) error

GetArticle godoc @Summary Get an article @Description Get an article. Auth not required @ID get-article-by-id @Tags article @Accept json @Produce json @Param id path int true "ID of the article to get" @Success 200 {object} singleArticleResponse @Failure 400 {object} utils.Error @Failure 500 {object} utils.Error @Router /articles/{id} [get]

func (*Handler) GetProfile

func (h *Handler) GetProfile(c *fiber.Ctx) 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 *fiber.Ctx) 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(r *fiber.App)

func (*Handler) SignUp

func (h *Handler) SignUp(c *fiber.Ctx) 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 {objects} utils.Error @Failure 500 {objects} utils.Error @Router /users [post]

func (*Handler) UpdateArticle

func (h *Handler) UpdateArticle(c *fiber.Ctx) error

UpdateArticle godoc @Summary Update an article @Description Update an article. Auth is required @ID update-article @Tags article @Accept json @Produce json @Param id path int true "ID 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/{id} [put]

func (*Handler) UpdateUser

func (h *Handler) UpdateUser(c *fiber.Ctx) 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]

type Validator

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

func NewValidator

func NewValidator() *Validator

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Jump to

Keyboard shortcuts

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