Documentation
¶
Index ¶
- Constants
- Variables
- func AppendLine(path string, content string) error
- func BytesToInt(b []byte) int
- func BytesToStruct(data []byte, inter interface{})
- func Contains(search interface{}, target interface{}) bool
- func ContainsIgnoreCase(search string, target []string) bool
- func FormValue(ctx iris.Context, name string) string
- func FormValueBool(ctx iris.Context, name string) (bool, error)
- func FormValueDefault(ctx iris.Context, name, def string) string
- func FormValueInt(ctx iris.Context, name string) (int, error)
- func FormValueInt64(ctx iris.Context, name string) (int64, error)
- func FormValueInt64Array(ctx iris.Context, name string) []int64
- func FormValueInt64Default(ctx iris.Context, name string, def int64) int64
- func FormValueIntDefault(ctx iris.Context, name string, def int) int
- func FormValueRequired(ctx iris.Context, name string) (string, error)
- func FormValueStringArray(ctx iris.Context, name string) []string
- func InitLog() error
- func IsEmpty(a interface{}) bool
- func MD5(str string) string
- func MD5Bytes(data []byte) string
- func MapToStruct(obj interface{}, data map[string]interface{}) error
- func PathExists(path string) (bool, error)
- func SqlNullString(value string) sql.NullString
- func StructFields(s interface{}) []reflect.StructField
- func StructName(s interface{}) string
- func StructToMap(obj interface{}, excludes ...string) map[string]interface{}
- func StructTypeOf(s interface{}) reflect.Type
- func WriteString(path string, content string, append bool) error
- type CursorResult
- type ErrorCode
- type OrderByCol
- type PageResult
- type Paging
- type ParamPair
- type QueryParams
- func (q *QueryParams) Asc(column string) *QueryParams
- func (q *QueryParams) Desc(column string) *QueryParams
- func (q *QueryParams) EqByReq(column string) *QueryParams
- func (q *QueryParams) GtByReq(column string) *QueryParams
- func (q *QueryParams) GteByReq(column string) *QueryParams
- func (q *QueryParams) LikeByReq(column string) *QueryParams
- func (q *QueryParams) Limit(limit int) *QueryParams
- func (q *QueryParams) LtByReq(column string) *QueryParams
- func (q *QueryParams) LteByReq(column string) *QueryParams
- func (q *QueryParams) NotEqByReq(column string) *QueryParams
- func (q *QueryParams) Page(page, limit int) *QueryParams
- func (q *QueryParams) PageByReq() *QueryParams
- type SLSHook
- type ServerConfig
- type SqlCnd
- func (s *SqlCnd) Asc(column string) *SqlCnd
- func (s *SqlCnd) Build(db *gorm.DB) *gorm.DB
- func (s *SqlCnd) Count(db *gorm.DB, model interface{}) int
- func (s *SqlCnd) Desc(column string) *SqlCnd
- func (s *SqlCnd) Ending(column string, str string) *SqlCnd
- func (s *SqlCnd) Eq(column string, args ...interface{}) *SqlCnd
- func (s *SqlCnd) Find(db *gorm.DB, out interface{})
- func (s *SqlCnd) FindOne(db *gorm.DB, out interface{}) error
- func (s *SqlCnd) Gt(column string, args ...interface{}) *SqlCnd
- func (s *SqlCnd) Gte(column string, args ...interface{}) *SqlCnd
- func (s *SqlCnd) In(column string, params interface{}) *SqlCnd
- func (s *SqlCnd) Like(column string, str string) *SqlCnd
- func (s *SqlCnd) Limit(limit int) *SqlCnd
- func (s *SqlCnd) Lt(column string, args ...interface{}) *SqlCnd
- func (s *SqlCnd) Lte(column string, args ...interface{}) *SqlCnd
- func (s *SqlCnd) NotEq(column string, args ...interface{}) *SqlCnd
- func (s *SqlCnd) Page(page, limit int) *SqlCnd
- func (s *SqlCnd) Starting(column string, str string) *SqlCnd
- func (s *SqlCnd) Where(query string, args ...interface{}) *SqlCnd
Constants ¶
View Source
const ( ProdEnv = "prod" AppPort = 10000 ReportDuration = 30 SS5ProxyPort = 19825 SS5ProxyConnectTimeOut = 5 HttpProxyPort = 21520 LogsPath = "./logs" InfoLogLevel = "info" )
Variables ¶
View Source
var ( ErrorCodeSystem = NewError(1000, "系统异常") ErrorCodeNotLogin = NewError(1, "请先登录") ErrorCodeParse = NewError(2, "解析错误") ErrorCodeNotFound = NewError(3, "未找到") ErrorCodeRegisterFailed = NewError(4, "用户注册失败") )
View Source
var ( Conf = &ServerConfig{} // 全局配置文件 Log = logrus.New() // Log API ProxyIp = "" // 代理 ip )
全局实例对象
Functions ¶
func AppendLine ¶
func BytesToInt ¶
func BytesToStruct ¶
func BytesToStruct(data []byte, inter interface{})
func ContainsIgnoreCase ¶
func FormValueInt64Default ¶
func MapToStruct ¶
func PathExists ¶
func SqlNullString ¶
func SqlNullString(value string) sql.NullString
func StructToMap ¶
func StructTypeOf ¶
Types ¶
type CursorResult ¶
type CursorResult struct {
Results interface{} `json:"results"` // 数据
Cursor string `json:"cursor"` // 下一页
}
Cursor分页返回数据
type ErrorCode ¶
type ErrorCode struct {
Code int
Message string
Data interface{}
Success bool
ErrorData interface{}
}
func NewErrorData ¶
type PageResult ¶
type PageResult struct {
Page *Paging `json:"page"` // 分页信息
Results interface{} `json:"results"` // 数据
}
分页返回数据
type Paging ¶
type Paging struct {
Page int `json:"page"` // 页码
Limit int `json:"limit"` // 每页条数
Total int `json:"total"` // 总数据条数
}
分页请求数据
type QueryParams ¶
func NewQueryParams ¶
func NewQueryParams(ctx iris.Context) *QueryParams
func (*QueryParams) Asc ¶
func (q *QueryParams) Asc(column string) *QueryParams
func (*QueryParams) Desc ¶
func (q *QueryParams) Desc(column string) *QueryParams
func (*QueryParams) EqByReq ¶
func (q *QueryParams) EqByReq(column string) *QueryParams
func (*QueryParams) GtByReq ¶
func (q *QueryParams) GtByReq(column string) *QueryParams
func (*QueryParams) GteByReq ¶
func (q *QueryParams) GteByReq(column string) *QueryParams
func (*QueryParams) LikeByReq ¶
func (q *QueryParams) LikeByReq(column string) *QueryParams
func (*QueryParams) Limit ¶
func (q *QueryParams) Limit(limit int) *QueryParams
func (*QueryParams) LtByReq ¶
func (q *QueryParams) LtByReq(column string) *QueryParams
func (*QueryParams) LteByReq ¶
func (q *QueryParams) LteByReq(column string) *QueryParams
func (*QueryParams) NotEqByReq ¶
func (q *QueryParams) NotEqByReq(column string) *QueryParams
func (*QueryParams) Page ¶
func (q *QueryParams) Page(page, limit int) *QueryParams
func (*QueryParams) PageByReq ¶
func (q *QueryParams) PageByReq() *QueryParams
type SLSHook ¶
type SLSHook struct {
// contains filtered or unexported fields
}
SLSHook 定义一个实现了logrus.Hook接口的SLSHook结构体
type ServerConfig ¶
type ServerConfig struct {
App struct {
Env string `yaml:"env"` // 运行环境,dev 与 prod, 默认为生产环境(prod),如果为开发环境,不生成文件日志
Port uint64 `yaml:"port"` // 应用本身暴露出的 http 服务的端口
ChangeIpCommand string `yaml:"changeIpCommand"` // agent 端用来更换 ip 的命令
Platform string `yaml:"platform"` //代理运行的云服务平台
Tags []string `yaml:"tags"` // 标签
Name string `yaml:"name" default:""`
} `yaml:"app"`
Report struct {
Url string `yaml:"url"` // 上报的 url
HostName string `yaml:"hostname"` // 上报信息中的 hostname, 如果没有指定,就获取本机的 hostname
Ip string `yaml:"ip"` // 代理ip,如果不指定,那就请求 http://httpbin.org/ip 获取自己的外网 ip
Duration int `yaml:"duration"` // 上报代理信息的周期
} `yaml:"report"`
NeedReport bool
Proxy struct {
Socks5 struct {
Enable bool `yaml:"enable"` // 是否开启 socks5 代理
Port int `yaml:"port"`
ConnectTimeout int `yaml:"connectTimeout"` // 代理服务器与目标网站连接超时时间, 默认5秒
UserAndPass []string `yaml:"userAndPass"`
UserAndPassMap map[string]string
} `yaml:"socks5"`
Http struct {
Enable bool `yaml:"enable"`
Port int `yaml:"port"`
UserAndPass []string `yaml:"userAndPass"`
UserAndPassMap map[string]string
} `yaml:"http"`
ShadowSocks struct {
Enable bool `yaml:"enable"` //是否开启shadowSocks代理
Port int `yaml:"port"` //监听端口
Cipher string `yaml:"cipher"` //加密方式
Password []string `yaml:"password"` //密码
WhiteList []string `yaml:"whiteList"` //域名白名单
BlackList []string `yaml:"blackList"` //域名黑名单
} `yaml:"shadowSocks"`
} `yaml:"proxy"`
Log struct {
Path string `yaml:"path"` // 日志存储的文件目录, 默认为当前目录下的 logs 目录下
Level string `yaml:"level"` // 日志打印级别, 默认为 info
SLS struct {
AccessKeyId string `yaml:"accessKeyId"`
AccessKeySecret string `yaml:"accessKeySecret"`
Project string `yaml:"project"`
Logstore string `yaml:"logstore"`
Endpoint string `yaml:"endpoint"`
Topic string `yaml:"topic"`
}
} `yaml:"log"`
Nacos struct {
Namespace string `yaml:"namespace"` //nacos的命名空间,public或者特定的命名空间
IpAddr string `yaml:"ipAddr"` // nacos服务的ip或者域名
Port uint64 `yaml:"port"` //nacos服务的端口
RegIp string `yaml:"regIp"` //注册到nacos的ip, private / public 内网或者外网,默认外网
} `yaml:"nacos"`
}
func (*ServerConfig) InitConfig ¶
func (conf *ServerConfig) InitConfig(filename string) error
func (*ServerConfig) PrettyString ¶
func (conf *ServerConfig) PrettyString() string
PrettyString returns a pretty-printed JSON representation of the ServerConfig
Source Files
¶
Click to show internal directories.
Click to hide internal directories.