helper

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash checks if the given passwords matches.

func DecodeError

func DecodeError(
	w http.ResponseWriter,
	r *http.Request,
	l *logger.Logger,
	apiErr string,
	code int,
)

DecodeError handles API errors.

func HashPassword

func HashPassword(password string, cost int) (string, error)

HashPassword encrypts a given password using bcrypt algorithm.

func MarshalBinary

func MarshalBinary(d interface{}) ([]byte, error)

MarshalBinary is a implementation of BinaryMarshaler interface.

func SearchValidatorMessage

func SearchValidatorMessage(w http.ResponseWriter)

SearchValidatorMessage handles search validation errors.

func UnmarshalBinary

func UnmarshalBinary(d []byte, v interface{}) error

UnmarshalBinary is a implementation of BinaryUnmarshaler interface.

func ValidatorMessage

func ValidatorMessage(w http.ResponseWriter, err error)

ValidatorMessage handles validation error messages.

Types

type APIMessage

type APIMessage struct {
	Message string `json:"message,omitempty"`
	Status  int    `json:"status,omitempty"`
}

APIMessage is a struct for generic JSON response.

type APIValidator

type APIValidator struct {
	Errors []*APIMessage `json:"errors"`
}

APIValidator type is a struct for multiple error messages.

Jump to

Keyboard shortcuts

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