Documentation ¶
Index ¶
- Constants
- func JSONResp(w http.ResponseWriter, code int, message string, data ...interface{})
- func JsonExit(w http.ResponseWriter, code int, message string, data ...interface{})
- func JsonRedirect(w http.ResponseWriter, code int, message, redirect string, data ...interface{})
- func JsonRedirectExit(w http.ResponseWriter, code int, message, redirect string, data ...interface{})
- func ToJsonFIle(w http.ResponseWriter, content io.ReadSeeker, fileTag string)
- func ToPlainText(w http.ResponseWriter, content []byte, fileName string)
- func ToXls(w http.ResponseWriter, content io.ReadSeeker, fileTag string)
- type DomainInfo
- type JsonRes
- type Payload
- type Request
- type Response
- type ResponseWithHeaders
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 JsonRes ¶
type JsonRes struct { Code int `json:"code"` // 错误码((0:成功, 1:失败, >1:错误码)) Message string `json:"message"` // 提示信息 Data interface{} `json:"data"` // 返回数据(业务接口定义具体数据结构) }
JsonRes 数据返回通用JSON数据结构
type Response ¶
type Response struct { Ret int `json:"ret"` Code string `json:"code"` Data interface{} `json:"data"` Message string `json:"message"` }
func ResponseFailed ¶
func ResponseSucess ¶
func ResponseSucess(data interface{}) Response
type ResponseWithHeaders ¶ added in v0.1.1
Click to show internal directories.
Click to hide internal directories.