links

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(c *gin.Context)

Create godoc

@Summary	Create new link
@Schemes
@Tags		Links
@Accept		json
@Produce	json
@Security	BearerAuth
@Param		request	body		LinkCreateValidator	true	"Request Body"
@Success	200		{object}	CreatedLinkResponse
@Failure	422		{object}	utils.CommonValidationError
@Failure	400		{object}	utils.CommonError
@Router		/links [post]

func Delete added in v0.7.2

func Delete(c *gin.Context)

Update godoc

@Summary	Delete link
@Schemes
@Tags		Links
@Accept		json
@Produce	json
@Security	BearerAuth
@Param		linkId	path	string	true	"Link ID"
@Success	204		"Empty response"
@Failure	404		{object}	utils.CommonError
@Router		/links/{linkId} [delete]

func GetAll

func GetAll(c *gin.Context)

GetAll godoc

@Summary	Get all links for user
@Schemes
@Tags		Links
@Accept		json
@Produce	json
@Security	BearerAuth
@Param		take	query		int	false	"Limit links per page"
@Param		page	query		int	false	"Page number"
@Success	200		{object}	db_utils.GetAllResponse{data=[]LinkResponse}
@Router		/links [get]

func GetOne added in v0.7.2

func GetOne(c *gin.Context)

Update godoc

@Summary	Get one link
@Schemes
@Tags		Links
@Accept		json
@Produce	json
@Security	BearerAuth
@Param		linkId	path		string	true	"Link ID"
@Success	204		{object}	LinkResponse
@Failure	404		{object}	utils.CommonError
@Router		/links/{linkId} [get]

func Redirect

func Redirect(c *gin.Context)

Redirect godoc

@Summary	Redirect from alias to realLink
@Schemes
@Tags		Links
@Accept		json
@Produce	json
@Param		alias	path	string	true	"Short URL Alias"
@Success	302		"Redirect"
@Failure	404		{object}	utils.CommonError
@BasePath	/
@Router		/{alias} [get]

func Router

func Router(route *gin.RouterGroup)

func Update

func Update(c *gin.Context)

Update godoc

@Summary	Update link
@Schemes
@Tags		Links
@Accept		json
@Produce	json
@Security	BearerAuth
@Param		linkId	path	string				true	"Link ID"
@Param		request	body	LinkUpdateValidator	true	"Request Body"
@Success	204		"Empty response"
@Failure	422		{object}	utils.CommonValidationError
@Failure	404		{object}	utils.CommonError
@Router		/links/{linkId} [patch]

Types

type CreatedLinkResponse

type CreatedLinkResponse struct {
	ID    uint   `json:"id"`
	Alias string `json:"alias"`
}

type CreatedLinkSerializer

type CreatedLinkSerializer struct {
	C *gin.Context
	models.LinkModel
}

func (*CreatedLinkSerializer) Response

type LinkCreateValidator

type LinkCreateValidator struct {
	Name    string `json:"name" binding:"max=150"`
	RealUrl string `json:"realUrl" binding:"required,url,min=5,max=2000"`
}

func NewLinkCreateValidator

func NewLinkCreateValidator() LinkCreateValidator

func (*LinkCreateValidator) Bind

func (v *LinkCreateValidator) Bind(c *gin.Context) error

type LinkResponse

type LinkResponse struct {
	ID        uint   `json:"id"`
	Name      string `json:"name"`
	RealUrl   string `json:"realUrl"`
	Alias     string `json:"alias"`
	CreatedAt string `json:"createdAt"`
}

type LinkSerializer

type LinkSerializer struct {
	C *gin.Context
	models.LinkModel
}

func (*LinkSerializer) Response

func (s *LinkSerializer) Response() LinkResponse

type LinkUpdateUriValidator

type LinkUpdateUriValidator struct {
	ID uint `json:"id" uri:"linkId"`
}

type LinkUpdateValidator

type LinkUpdateValidator struct {
	Name string `json:"name" binding:"max=150"`
}

func NewLinkUpdateValidator

func NewLinkUpdateValidator() LinkUpdateValidator

func (*LinkUpdateValidator) Bind

func (v *LinkUpdateValidator) Bind(c *gin.Context) error

type LinksSerializer

type LinksSerializer struct {
	C           *gin.Context
	Links       []models.LinkModel
	TotalCount  int64
	Took        int
	CurrentPage int
}

func (*LinksSerializer) Response

func (s *LinksSerializer) Response() db_utils.GetAllResponse

type RedirectUriValidator

type RedirectUriValidator struct {
	Alias string `json:"alias" uri:"alias"`
}

Jump to

Keyboard shortcuts

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