-
Notifications
You must be signed in to change notification settings - Fork 3
/
gin.custom.go
47 lines (37 loc) · 1 KB
/
gin.custom.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package golog
import (
"context"
"github.com/dtapps/go-library/utils/goip"
)
type GinCustomClient struct {
ipService *goip.Client // IP服务
config struct {
systemHostname string // 主机名
systemOs string // 系统类型
systemKernel string // 系统内核
systemInsideIp string // 内网ip
systemOutsideIp string // 外网ip
goVersion string // go版本
sdkVersion string // sdk版本
}
slog struct {
status bool // 状态
client *SLog // 日志服务
}
}
type ConfigGinCustomClient struct {
IpService *goip.Client // IP服务
CurrentIp string // 当前IP
}
func NewGinCustomClient(ctx context.Context, config *ConfigGinCustomClient) (*GinCustomClient, error) {
c := &GinCustomClient{}
c.config.systemOutsideIp = config.CurrentIp
c.config.systemOutsideIp = goip.IsIp(c.config.systemOutsideIp)
if c.config.systemOutsideIp == "" {
return nil, currentIpNoConfig
}
c.ipService = config.IpService
// 配置信息
c.setConfig(ctx)
return c, nil
}