core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package core implements some core functions used by apimachinery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteResponse

func WriteResponse(c *gin.Context, err error, data interface{})

WriteResponse 将错误或响应数据写入 HTTP 响应主体。 WriteResponse 使用 errno.Decode 方法,根据错误类型,尝试从 err 中提取业务错误码和错误信息.

Types

type ErrResponse

type ErrResponse struct {
	// Code 指定了业务错误码.
	Code string `json:"code"`

	// Message 包含了可以直接对外展示的错误信息.
	Message string `json:"message"`
}

ErrResponse 定义了发生错误时的返回消息.

Jump to

Keyboard shortcuts

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