contracts

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxKeyForRequest = "NfHttpRequestObject"
	DomainInfoCode   = "DomainInfoCode"
)

Variables

This section is empty.

Functions

func JSONResp

func JSONResp(w http.ResponseWriter, code int, message string, data ...interface{})

JSONResp 返回标准JSON数据。

func JsonExit

func JsonExit(w http.ResponseWriter, code int, message string, data ...interface{})

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

func JsonRedirect

func JsonRedirect(w http.ResponseWriter, code int, message, redirect string, data ...interface{})

JsonRedirect 返回标准JSON数据引导客户端跳转。

func JsonRedirectExit

func JsonRedirectExit(w http.ResponseWriter, code int, message, redirect string, data ...interface{})

JsonRedirectExit 返回标准JSON数据引导客户端跳转,并退出当前HTTP执行函数。

func ToJsonFIle

func ToJsonFIle(w http.ResponseWriter, content io.ReadSeeker, fileTag string)

ToJsonFIle 向前端返回文件 参数 content 为上面生成的io.ReadSeeker, fileTag 为返回前端的文件名

func ToPlainText

func ToPlainText(w http.ResponseWriter, content []byte, fileName string)

ToPlainText 输出流

func ToXls

func ToXls(w http.ResponseWriter, content io.ReadSeeker, fileTag string)

ToXls 向前端返回Excel文件 参数 content 为上面生成的io.ReadSeeker, fileTag 为返回前端的文件名

Types

type DomainInfo added in v0.1.0

type DomainInfo struct {
	FullDomain  string
	SubDomain   string
	SecondLevel string
	TopLevel    string
}

type JsonRes

type JsonRes struct {
	Code    int         `json:"code"`    // 错误码((0:成功, 1:失败, >1:错误码))
	Message string      `json:"message"` // 提示信息
	Data    interface{} `json:"data"`    // 返回数据(业务接口定义具体数据结构)
}

JsonRes 数据返回通用JSON数据结构

type Payload

type Payload struct {
	Route  string                 `json:"route"`
	Params map[string]interface{} `json:"params"`
}

type Request

type Request struct {
	Id   string `json:"request_id"`
	Data map[string]interface{}
}

type Response

type Response struct {
	Ret     int         `json:"ret"`
	Code    string      `json:"code"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
}

func ResponseFailed

func ResponseFailed(err error) Response

func ResponseSucess

func ResponseSucess(data interface{}) Response

type ResponseWithHeaders added in v0.1.1

type ResponseWithHeaders struct {
	Headers map[string]string
	Data    interface{}
}

Jump to

Keyboard shortcuts

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