httper

package
v0.0.0-...-35a45e1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindAndCheck

func BindAndCheck(ctx *gin.Context, data interface{}) bool

BindAndCheck 绑定参数并验证参数 true: 确实存在问题,会返回400错误 false: 不存在问题,验证通过

func HandleResponse

func HandleResponse(c *gin.Context, err error, data interface{})

HandleResponse 统一处理异常,统一处理日志,统一处理返回

func SendFailResp

func SendFailResp(c *gin.Context, httpCode int, message string)

SendFailResp 返回失败请求

func SendResp

func SendResp(c *gin.Context, httpCode, code int, message string, data interface{})

SendResp 返回自定义数据

func SendSuccessResp

func SendSuccessResp(c *gin.Context, message string, data interface{})

SendSuccessResp 返回成功请求

Types

type Response

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

Response 通用返回模型

Jump to

Keyboard shortcuts

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