helper

package
v0.0.0-...-44947e2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RespondJSON

func RespondJSON(w *gin.Context, status int, message string, payload interface{}, errors interface{})

RespondJSON : send a proper response json to the client

func SetFirstLetterToLowerCase

func SetFirstLetterToLowerCase(toBeConvertedString string) string

SetFirstLetterToLowerCase : Function to set first letter of string to lower case. This function exist because struct field name must start with capital letter This function is useful so the front end can detect which field has an error

Types

type ErrorField

type ErrorField struct {
	ID      string `json:"id"`
	Value   string `json:"value"`
	Caused  string `json:"caused"`
	Message string `json:"message"`
}

ErrorField : 422 error validation format

func ConstructErrors

func ConstructErrors(err error) []ErrorField

ConstructErrors : Function to construct errors to be used in response

type ResponseData

type ResponseData struct {
	Success bool        `json:"success"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
	Error   interface{} `json:"error"`
}

ResponseData : response format

Jump to

Keyboard shortcuts

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