v2

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success = "success"
	Error   = "error"
	Status  = "status"
)

Variables

This section is empty.

Functions

func EncodeQuery added in v1.7.0

func EncodeQuery(param map[string]string) string

func ErrorHandleMiddleware added in v1.7.0

func ErrorHandleMiddleware() gin.HandlerFunc

func JsonResponse added in v1.7.0

func JsonResponse(c *gin.Context, httpCode int, code int, obj any)

func RegisterCRUDApi

func RegisterCRUDApi(route *gin.Engine, pathPrefix string, api CRUDApi, middlewares ...gin.HandlerFunc)

func Response

func Response(c *gin.Context, obj any)

func ResponseError

func ResponseError(c *gin.Context, err error)

Types

type CRUDApi

type CRUDApi interface {
	Get(c *gin.Context)
	List(c *gin.Context)
	Create(c *gin.Context)
	Update(c *gin.Context)
	Delete(c *gin.Context)
}

type Code added in v1.7.0

type Code struct {
	// contains filtered or unexported fields
}

func NewCode added in v1.7.0

func NewCode(code int, httpStatus int) *Code

type ErrorResponse added in v1.7.0

type ErrorResponse struct {
	HttpStatus int

	// in: body
	Payload struct {
		// error code
		Code int `json:"code"`
		// error message
		Message string `json:"message"`
	} `json:"body"`
	// contains filtered or unexported fields
}

swagger:response errorResponse

func NewErrorResponse added in v1.7.0

func NewErrorResponse() *ErrorResponse

func (*ErrorResponse) WithError added in v1.7.0

func (r *ErrorResponse) WithError(err error) *ErrorResponse

func (*ErrorResponse) WriteResponse added in v1.7.0

func (r *ErrorResponse) WriteResponse(ctx *gin.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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