response

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeSuccess       = 200
	CodeNotFound      = 404
	CodeInternalError = 500
)

响应码定义

Variables

This section is empty.

Functions

func Error

func Error(c *gin.Context, message string)

Error 错误响应

func NotFound

func NotFound(c *gin.Context, message string)

NotFound 未找到响应

func Success

func Success(c *gin.Context, data interface{})

Success 成功响应

Types

type ProxyData

type ProxyData struct {
	IP        string `json:"ip"`        // IP地址
	Port      string `json:"port"`      // 端口
	Type      string `json:"type"`      // 代理类型
	Anonymous bool   `json:"anonymous"` // 是否高匿
	Speed     int64  `json:"speed_ms"`  // 响应速度(毫秒)
	Score     int    `json:"score"`     // 可用性评分
}

ProxyData 代理数据结构

func ConvertProxies

func ConvertProxies(proxies []*model.Proxy) []ProxyData

ConvertProxies 转换代理列表

func ConvertProxy

func ConvertProxy(proxy *model.Proxy) ProxyData

ConvertProxy 转换代理模型为响应数据

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