response

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BuildBy = time.Now()

BuildBy BuildBy

View Source
var DuplicateEntryKey, _ = regexp.Compile(
	`Duplicate entry '(.*)' for key '(.*)\.(.*)'`,
)

DuplicateEntryKey DuplicateEntryKey

View Source
var ErrorCodeText = map[ErrCode]string{

	Success: "获取成功",
	Errors:  "遇到错误",

	LoginSuccess:   "登陆成功",
	AuthedError:    "登陆超时",
	NotFound:       "没有数据",
	RepeatEmail:    "邮箱已存在",
	RepeatUserName: "用户名已存在",
	BindJSONErr:    "绑定失败,请检查参数",

	NoRoute:  "路由不存在",
	NoMethod: "方法不存在",
}

ErrorCodeText 错误提示

Functions

func LogError

func LogError(err interface{})

LogError LogError

func StatusText

func StatusText(code ErrCode) string

StatusText StatusText

Types

type ErrCode

type ErrCode int

ErrCode 错误码类型

const (
	// Success Success
	Success ErrCode = 1
	// Errors 失败
	Errors ErrCode = -1
	// NoRoute NoRoute
	NoRoute ErrCode = http.StatusNotFound
	// NoMethod NoMethod
	NoMethod ErrCode = http.StatusMethodNotAllowed
)
const (
	// AuthedError 认证失败
	AuthedError ErrCode = -iota - 100
	// NotFound 没有数据
	NotFound
	// RepeatEmail 邮箱已存在
	RepeatEmail
	// RepeatUserName 用户名已存在
	RepeatUserName
	// BindJSONErr 绑定json失败
	BindJSONErr
)
const (
	// LoginSuccess 登陆成功
	LoginSuccess ErrCode = iota + 100
)

type Result

type Result struct {
	Code    ErrCode     `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
	BuildBy time.Time   `json:"build_by"`
}

Result Result

func JSON

func JSON(code ErrCode, message string, data interface{}) Result

JSON JSON

func JSONError

func JSONError(message string, data interface{}) Result

JSONError JSONError

func JSONSuccess

func JSONSuccess(message string, data interface{}) Result

JSONSuccess 成功

func ParseError

func ParseError(r interface{}) Result

ParseError ParseError

Jump to

Keyboard shortcuts

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