jsonRespKit

package
v3.0.908 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package jsonRespKit

Deprecated: Use i18nRespKit instead.

This package is frozen and no new functionality will be added.

Index

Constants

This section is empty.

Variables

View Source
var (
	NotSetupError = errorKit.Newf("haven’t been set up correctly")
)

Functions

func MustSetUp deprecated

func MustSetUp(respProvider RespProvider, options ...Option)

MustSetUp 必须初始化.

Deprecated: Use i18nRespKit instead.

func Pack

func Pack(code string, data interface{}, msgArgs ...interface{}) interface{}

Pack 封装成响应结构体实例.

PS: 需要先成功调用 MustSetUp || SetUp.

func PackFully

func PackFully(code, msg string, data interface{}, msgArgs ...interface{}) interface{}

PackFully

PS: 需要先成功调用 MustSetUp || SetUp.

func Seal

func Seal(code string, data interface{}, msgArgs ...interface{}) (string, error)

Seal 封装成响应结构体实例,再序列化为json.

PS: 需要先成功调用 MustSetUp || SetUp.

func SealFully

func SealFully(code, msg string, data interface{}, msgArgs ...interface{}) (string, error)

SealFully 封装成响应结构体实例,再序列化为json.

PS: 需要先成功调用 MustSetUp || SetUp.

func SetUp deprecated

func SetUp(respProvider RespProvider, options ...Option) (err error)

SetUp

Deprecated: Use i18nRespKit instead.

Types

type FileData

type FileData struct {
	// Type 文件的类型,e.g. "properties"、"yaml"、"ini"...
	Type string

	// Data 文件的内容
	Data []byte
}

type Option

type Option func(opts *options)

func WithFileDataSlice

func WithFileDataSlice(fileDataSlice []*FileData) Option

WithFileDataSlice 存储code和msg对应关系的文件(类型、内容)

func WithFilePaths

func WithFilePaths(filePathSlice []string) Option

WithFilePaths 存储code和msg对应关系的文件(路径)

type RespProvider

type RespProvider func(code, msg string, data interface{}) interface{}

RespProvider

@return (1) 返回值是一个结构体实例指针
		(2) 结构体建议加上json tag

Jump to

Keyboard shortcuts

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