Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(c *fiber.Ctx) error
Delete function removes an user by ID @Summary Remove user by ID @Description Remove user by ID @Tags users @Accept json @Produce json @Param id path int true "User ID" @Success 200 {object} response.HTTP @Security ApiKeyAuth @Router /v1/users/{id} [delete]
func GetAll ¶
func GetAll(c *fiber.Ctx) error
GetAll is a function to get all users data from database @Summary Get all users @Description Get all users @Tags users @Accept json @Produce json @Success 200 {object} response.HTTP{data=[]User} @Router /v1/users [get]
func Login ¶
func Login(c *fiber.Ctx) error
Login signs user to a session @Summary User login @Description User login @Tags auth @Accept json @Produce json @Param user body LoginUser true "User login" @Success 200 {object} response.HTTP{data=ResponseAuth} @Router /v1/login [post]
func New ¶
func New(c *fiber.Ctx) error
New registers a new user data @Summary Register a new user @Description Register user @Tags auth @Accept json @Produce json @Param user body RegisterUser true "Register user" @Success 200 {object} response.HTTP{data=ResponseAuth} @Router /v1/register [post]
func Update ¶
func Update(c *fiber.Ctx) error
Update function edit an user by ID @Summary Update user by ID @Description Update user by ID @Tags users @Accept json @Produce json @Param id path int true "User ID" @Param user body UpdateUser true "Update user" @Success 200 {object} response.HTTP{data=User} @Security ApiKeyAuth @Router /v1/users/{id} [put]
Types ¶
type LoginUser ¶
type LoginUser struct { Email string `json:"email" example:"dinopuguh@mycap.com"` Password string `json:"password" example:"s3cr3tp45sw0rd"` }
LoginUser is a data transfer object for user login
type RegisterUser ¶
type RegisterUser struct { Name string `json:"name" example:"Dino Puguh"` Username string `json:"username" example:"dinopuguh"` Email string `json:"email" example:"dinopuguh@mycap.com"` Password string `json:"password" example:"s3cr3tp45sw0rd"` TypeID uint `json:"type_id" example:"1"` // (1: Free, 2: Premium, 3: Pro) }
RegisterUser is a data transfer object for create user
type ResponseAuth ¶
ResponseAuth represents response body for authenticated user
type UpdateUser ¶
type UpdateUser struct { Name string `json:"name" example:"Dino Puguh"` RemainingTime int64 `json:"remaining_time" example:"1800"` ReachedTimeLimit bool `json:"reached_time_limit" example:"false"` TypeID uint `json:"type_id" example:"2"` // (1: Free, 2: Premium, 3: Pro) }
UpdateUser is a data transfer object for update user
type User ¶
type User struct { gorm.Model Name string `json:"name"` Username string `json:"username"` Email string `json:"email"` Password string `json:"password"` RemainingTime int64 `json:"remaining_time" gorm:"default:36000000;"` ReachedTimeLimit bool `json:"reached_time_limit" gorm:"default:false;"` Type Type `json:"type"` TypeID uint `json:"type_id"` }
User is a model for user