shared

package
v1.1.17 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RespondWith added in v1.0.147

func RespondWith(c *gin.Context, status int, dataField interface{}, error string, code ReturnCode)

RespondWith will respond with the generic API response

func RespondWithInvalidAppContext added in v1.0.147

func RespondWithInvalidAppContext(c *gin.Context)

RespondWithInvalidAppContext will be called when the application's context is invalid

func RespondWithValidationError added in v1.0.147

func RespondWithValidationError(c *gin.Context, error string)

RespondWithValidationError will be called when the application's context is invalid

Types

type GenericAPIResponse

type GenericAPIResponse struct {
	Data  interface{} `json:"data"`
	Error string      `json:"error"`
	Code  ReturnCode  `json:"code"`
}

GenericAPIResponse defines the structure of all responses on API endpoints

type ReturnCode

type ReturnCode string

ReturnCode defines the type defines to identify return codes

const ReturnCodeInternalError ReturnCode = "internal_issue"

ReturnCodeInternalError defines a request which hasn't been executed successfully due to an internal error

const ReturnCodeRequestError ReturnCode = "bad_request"

ReturnCodeRequestError defines a request which hasn't been executed successfully due to a bad request received

const ReturnCodeSuccess ReturnCode = "successful"

ReturnCodeSuccess defines a successful request

const ReturnCodeSystemBusy ReturnCode = "system_busy"

ReturnCodeSystemBusy defines a request which hasn't been executed successfully due to too many requests

Jump to

Keyboard shortcuts

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