helper

package
v0.0.0-...-ec4765f Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package helper for handling response to client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIErrorResponse

func APIErrorResponse(c *gin.Context, statusCode int, err interface{})

APIErrorResponse will send JSON response with error value to the client

func APIResponse

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

APIResponse will send JSON response to the client and some additional detail

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash will compare 'hashed' password with the 'input' password

func EmailIsValid

func EmailIsValid(email string) bool

EmailIsValid will check whether given email was valid

func GenerateSecureKey

func GenerateSecureKey(length int) (string, error)

GenerateSecureKey will create 'Secure Key' with given length

func HashPassword

func HashPassword(password string) (string, error)

HashPassword will generated hashed password so it wont easily be roken by unauthorized person

func PasswordTooShort

func PasswordTooShort(password string) bool

PasswordTooShort will check whether password length is not match the minimum password lenght for the user account

Types

type ErrorResponse

type ErrorResponse struct {
	Status int         `json:"status"`
	Method string      `json:"method"`
	Error  interface{} `json:"error"`
}

ErrorResponse is a response that containing error Details of the error shoul not be technical as it will be sent to the user

type Response

type Response struct {
	Status  int         `json:"status"`
	Method  string      `json:"method"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

Response is response helper to send to client/ user

Jump to

Keyboard shortcuts

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