helpers

package
v0.0.0-...-a7c99a5 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2018 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//Common error
	ErrorMissingParameter = 10

	//Error about User
	ErrorExistEmail            = 101
	ErrorExistUsername         = 102
	ErrorExistEmailAndUsername = 103
	ErrorExistStudentCode      = 113
)

const

View Source
const (
	GraphFacebookAPI = "https://graph.facebook.com"
)

const

View Source
const (
	//SMTPSever const stror link email smtp
	SMTPSever = "smtp.gmail.com"
)

Variables

This section is empty.

Functions

func ConvertSort

func ConvertSort(input string) (string, error)

ConvertSort func return a string for Query work ORDER BY, eg: input '+created_at' output 'created_at DESC'

func ExtractClaims

func ExtractClaims(tokenstring string, secret []byte) (jwt.MapClaims, error)

ExtractClaims func to get map claims

func GenerateToken

func GenerateToken(account models.Account, secret []byte) (string, error)

GenerateToken func to set token for a new login

func IsZeroOfUnderlyingType

func IsZeroOfUnderlyingType(x interface{}) bool

IsZeroOfUnderlyingType return wether x is the is the zero-value of its underlying type.

func RandNumberBytes

func RandNumberBytes(n int) string

RandNumberBytes fun return a random number's string with n characters

func RandStringBytes

func RandStringBytes(n int) string

RandStringBytes fun return a random string with n characters

func Replace

func Replace(a, b interface{}) error

Replace replaces all fields of struct b that have a zero-value with the corresponding field value from a. b must be a pointer to a struct.

func ResponseAuthJSON

func ResponseAuthJSON(c *gin.Context, code int, message string)

ResponseAuthJSON func

func ResponseBadRequestJSON

func ResponseBadRequestJSON(c *gin.Context, code int, message interface{})

ResponseBadRequestJSON func

func ResponseCreatedJSON

func ResponseCreatedJSON(c *gin.Context, code int, message string, data interface{})

ResponseCreatedJSON func

func ResponseEntityListJSON

func ResponseEntityListJSON(c *gin.Context, code int, message string, entityList interface{}, metadata interface{}, total int)

ResponseEntityListJSON func

func ResponseErrorJSON

func ResponseErrorJSON(c *gin.Context, error ErrorDetail)

ResponseErrorJSON func

func ResponseErrorsJSON

func ResponseErrorsJSON(c *gin.Context, errors Errors)

ResponseErrorsJSON func

func ResponseForbiddenJSON

func ResponseForbiddenJSON(c *gin.Context, code int, message interface{})

ResponseForbiddenJSON func

func ResponseJSON

func ResponseJSON(c *gin.Context, status int, code int, message string, data interface{})

ResponseJSON func

func ResponseNoContentJSON

func ResponseNoContentJSON(c *gin.Context)

ResponseNoContentJSON func

func ResponseNotFoundJSON

func ResponseNotFoundJSON(c *gin.Context, code int, message string)

ResponseNotFoundJSON func

func ResponseServerErrorJSON

func ResponseServerErrorJSON(c *gin.Context)

ResponseServerErrorJSON func

func ResponseSuccessJSON

func ResponseSuccessJSON(c *gin.Context, code int, message string, data interface{})

ResponseSuccessJSON func

func ValidateToken

func ValidateToken(tokenstring string, secret []byte) (bool, error)

ValidateToken func to authen token

func VerifyFacebookID

func VerifyFacebookID(id string, accessToken string) bool

VerifyFacebookID func to check logged in via Facebook

Types

type ErrorDetail

type ErrorDetail struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorDetail struct for a Error

func NewErrorDetail

func NewErrorDetail(c int, m string) ErrorDetail

NewErrorDetail func to create and return a new ErrorDetail

type Errors

type Errors struct {
	Code         int           `json:"code"`
	Message      string        `json:"message"`
	ErrorDetails []ErrorDetail `json:"error_details"`
}

Errors struct include a or a few errors

type ParamsGetAll

type ParamsGetAll struct {
	Filter     string                 `json:"filter,omitempty"`
	Sort       string                 `json:"sort,omitempty"`
	Skip       int                    `json:"skip,omitempty"`
	Limit      int                    `json:"limit,omitempty"`
	Type       string                 `json:"type,omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty"`
}

ParamsGetAll struct

type Sender

type Sender struct {
	User     string
	Password string
}

Sender struct include of user password

func NewSender

func NewSender(Username, Password string) Sender

NewSender func to return a new sender

func (Sender) SendMail

func (sender Sender) SendMail(Dest []string, Subject, bodyMessage string)

SendMail func to send a mail to many dest with subject and body message

Jump to

Keyboard shortcuts

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