response

package
v0.0.0-...-dffa276 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorJSON

func ErrorJSON(c *gin.Context, status int, messageTypes *MessageTypes, err error)

ErrorJSON is a json response of errors.

func JSON

func JSON(c *gin.Context, status int, messageTypes *MessageTypes, messages *Messages, err error)

JSON is a json response.

func KnownErrorJSON

func KnownErrorJSON(c *gin.Context, status int, messageType string, err error)

KnownErrorJSON is json response of known error.

func RedirectionJSON

func RedirectionJSON(c *gin.Context, status int, messageType string, msg string)

RedirectionJSON is a json response of 3xx.

func SuccessJSON

func SuccessJSON(c *gin.Context, status int, messageType string, msg string)

SuccessJSON is a json response of 2xx.

func UnknownErrorJSON

func UnknownErrorJSON(c *gin.Context, status int, err error)

UnknownErrorJSON is json response of unknown error.

Types

type BasicResponse

type BasicResponse struct {
	Status      int    `json:"status",description:"http status"`
	MessageType string `json:"messageType", description:"response message type for frontend I18N."`
	Message     string `json:"message",description:"response message"`
}

BasicResponse is a basic response.

func KnownError

func KnownError(status int, messageType string, err error) *BasicResponse

KnownError is a basic response of know errors.

func Redirection

func Redirection(status int, messageType string, msg string) *BasicResponse

Redirection is a basic response of 3xx.

func Success

func Success(status int, messageType string, msg string) *BasicResponse

Success is a basic response of 2xx.

func UnknownError

func UnknownError(status int, err error) *BasicResponse

UnknownError is a basic response of unknown errors.

type MessageTypes

type MessageTypes struct {
	OK                  string `description:"200"`
	Created             string `description:"201"`
	NotModified         string `description:"304"`
	BadRequest          string `description:"400"`
	Unauthorized        string `description:"401"`
	PaymentRequired     string `description:"402"`
	Forbidden           string `description:"403"`
	NotFound            string `description:"404"`
	MethodNotAllowed    string `description:"405"`
	InternalServerError string `description:"500"`
}

MessageTypes is an array of message types that using in frontend. OK : 200 Created : 201 NotModified : 304 BadRequest : 400 Unauthorized : 401 PaymentRequired : 402 Forbidden : 403 NotFound : 404 MethodNotAllowed : 405 InternalServerError : 500

type Messages

type Messages struct {
	OK      string `description:"200"`
	Created string `description:"201"`
}

Messages is an array of messages

Jump to

Keyboard shortcuts

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