helpers

package
v0.0.0-...-6192489 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package helpers implements commonly used functions (response API)//

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirectResponse

func DirectResponse(w http.ResponseWriter, httpStatus int, data interface{})

DirectResponse is

func GenerateToken

func GenerateToken(user models.User) (t models.TokenResp, err error)

GenerateToken generate token JWT

func Response

func Response(w http.ResponseWriter, httpStatus int, data interface{})

Response is

func SetBody

func SetBody(Body map[string]interface{}) (io.Reader, error)

SetBody func

Types

type APIResponse

type APIResponse struct {
	Message interface{} `json:"message"`
}

APIResponse is

type JSONResponse

type JSONResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Error   string      `json:"error"`
	Data    interface{} `json:"data"`
}

JSONResponse represent a json response

type Page

type Page struct {
	CurrentPage  int `json:"current_page"`
	TotalPages   int `json:"total_pages"`
	TotalData    int `json:"total_data"`
	NextPage     int `json:"next_page"`
	PreviousPage int `json:"previous_page"`
}

Page data sturct

type PageReq

type PageReq struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
	Page   int `json:"page"`
}

PageReq data sturct

type Pages

type Pages struct {
	Page       int `json:"page"`
	PerPage    int `json:"per_page"`
	PageCount  int `json:"page_count"`
	TotalCount int `json:"total_count"`
}

Pages data sturct

func NewPaginate

func NewPaginate(page, perPage, total int) *Pages

NewPaginate is s

func (*Pages) NextPage

func (p *Pages) NextPage() int

NextPage is ss

func (*Pages) PrevPage

func (p *Pages) PrevPage() int

PrevPage is a

type Paginate

type Paginate struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Error   string      `json:"error"`
	Page    Page        `json:"page"`
	Data    interface{} `json:"data"`
}

Paginate data sturct

func WrapPaginate

func WrapPaginate(pages *Pages, data interface{}) *Paginate

WrapPaginate wraping paginate

Jump to

Keyboard shortcuts

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