responses

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InternalError        = 100000
	InputValidationError = 100001
	Unauthorized         = 100002
)

Variables

View Source
var (
	PathUsername = "data.username"
	PathPassword = "data.password"
	PathEmail    = "data.email"

	UsernameExists   = "username already exists"
	UsernameTooShort = "username too short"
	EmailExists      = "email address already exists"
	EmailIncorrect   = "email address incorrect"
	PasswordTooShort = "password too short"

	WrongUsernamePassword = "wrong username or password"
	UserInactive          = "user is inactive"

	InsufficientPermissionOrNonExistentResource = "user has insufficient permissions for this action or the resource does not exist"
)

Functions

func GraphQLError

func GraphQLError(message string, requestID string) error

func GraphQLInternalError

func GraphQLInternalError(originalError error, requestID string) error

func JSON

func JSON(c *gin.Context, code int, obj interface{})

JSON serializes the given struct as JSON into the response body. It also sets the Content-Type as "application/json".

func JSONAbort

func JSONAbort(c *gin.Context, code int, obj interface{})

func RecoveryHandler

func RecoveryHandler(c *gin.Context, err interface{})

func RenderInternalError

func RenderInternalError(c *gin.Context, code int, obj interface{}) (int, interface{})

Types

type Error

type Error struct {
	Result       string `json:"Result" description:"Whether the call was successful." enum:"success,error"`
	ErrorCode    int    `json:"Code" description:"The code of the error."`
	ErrorMessage string `json:"Message" description:"The human message of the error."`
	RequestId    string `json:"RequestId" description:"A request ID for support and debugging purposes."`
}

The serializable Error structure.

type RequestError

type RequestError struct {
	Code    int
	Message string
}

func (RequestError) Error

func (r RequestError) Error() string

type RequestInternalError

type RequestInternalError struct {
	OriginalError error
	Code          int
	Message       string
}

func (RequestInternalError) Error

func (r RequestInternalError) Error() string

type Success

type Success struct {
	Result    string      `json:"Result" description:"Whether the call was successful." enum:"success,error"`
	Data      interface{} `json:"Data"`
	RequestId string      `json:"RequestId" description:"A request ID for support and debugging purposes."`
}

Jump to

Keyboard shortcuts

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