libResponse

package
v0.0.0-...-14a2a1b Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessCode int = 0
	ErrorCode   int = -1
)

Variables

This section is empty.

Functions

func FailJson

func FailJson(isExit bool, r *ghttp.Request, msg string, data ...interface{})

func JsonExit

func JsonExit(r *ghttp.Request, code int, msg string, data ...interface{})

func RJson

func RJson(r *ghttp.Request, code int, msg string, data ...interface{})

func SusJson

func SusJson(isExit bool, r *ghttp.Request, msg string, data ...interface{})

func WriteTpl

func WriteTpl(r *ghttp.Request, tpl string, view *gview.View, params ...gview.Params) error

Types

type Response

type Response struct {
	// 代码
	Code int `json:"code" example:"200"`
	// 数据集
	Data interface{} `json:"data"`
	// 消息
	Msg string `json:"message"`
}

func (*Response) FailJson

func (res *Response) FailJson(isExit bool, r *ghttp.Request, msg string, data ...interface{})

失败返回JSON

func (*Response) JsonExit

func (res *Response) JsonExit(r *ghttp.Request, code int, msg string, data ...interface{})

返回JSON数据并退出当前HTTP执行函数。

func (*Response) RJson

func (res *Response) RJson(r *ghttp.Request, code int, msg string, data ...interface{})

标准返回结果数据结构封装。 返回固定数据结构的JSON: code: 状态码(200:成功,302跳转,和http请求状态码一至); msg: 请求结果信息; data: 请求结果,根据不同接口返回结果的数据结构不同;

func (*Response) Redirect

func (res *Response) Redirect(r *ghttp.Request, location string, code ...int)

func (*Response) SusJson

func (res *Response) SusJson(isExit bool, r *ghttp.Request, msg string, data ...interface{})

成功返回JSON

func (*Response) WriteTpl

func (res *Response) WriteTpl(r *ghttp.Request, tpl string, view *gview.View, params ...gview.Params) error

WriteTpl 模板输出

Jump to

Keyboard shortcuts

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