feat 初次提交

This commit is contained in:
2026-01-03 14:26:08 +08:00
parent ebeb244e1e
commit 887cb242e3
30 changed files with 1918 additions and 0 deletions

42
config/config.dev.yaml Normal file
View File

@@ -0,0 +1,42 @@
app:
name: "gateway-dev"
log:
debug: true
level: "debug"
maxSize: 10
maxBackups: 100
maxAge: 7
metric:
prometheus:
address: "0.0.0.0"
port: 8504
db:
etcd:
endpoints: [ "10.0.40.9:2379" ]
redis:
addr: "47.108.184.184:6379"
password: "lQ7aM8oB6lK0iD5k"
db: 0
serve:
grpc:
address: "10.0.40.199"
port: 8500
ttl: 20
socket:
web:
address: "0.0.0.0"
port: 8501
raw:
address: "0.0.0.0"
port: 8502
http:
address: "0.0.0.0"
port: 8503
auth:
secret: "bMa3mU4oCsX2KBex5o7GzwSnACpumFq3SdlDXYZgVTU="
expire: 259200

39
config/config.go Normal file
View File

@@ -0,0 +1,39 @@
package config
import "common/config"
const (
path = "./config"
KeyUserAccessToken = "user:access:%v"
KeyUserRefreshToken = "user:refresh:%v"
)
// PublicPaths 不需要鉴权的接口,硬编码注册
var PublicPaths = []string{
"/user/info",
}
type Config struct {
App *config.AppConfig `yaml:"app"`
Log *config.LogConfig `yaml:"log"`
Metric *config.MetricConfig `yaml:"metric"`
DB *config.DBConfig `yaml:"db"`
Serve *config.ServeConfig `yaml:"serve"`
Auth *struct {
Secret string `yaml:"secret"`
Expire int64 `yaml:"expire"`
}
}
var cfg *Config
// LoadConfig 加载应用配置
func LoadConfig() error {
c, err := config.LoadConfig(path, cfg)
cfg = c
return err
}
func Get() *Config {
return cfg
}

42
config/config.prod.yaml Normal file
View File

@@ -0,0 +1,42 @@
app:
name: "gateway-prod"
log:
debug: false
level: "debug"
maxSize: 10
maxBackups: 100
maxAge: 7
metric:
prometheus:
address: "0.0.0.0"
port: 8504
db:
etcd:
endpoints: [ "172.18.28.0:2379" ]
redis:
addr: "172.18.28.0:6379"
password: "lQ7aM8oB6lK0iD5k"
db: 0
serve:
grpc:
address: "172.18.28.0"
port: 8500
ttl: 20
socket:
web:
address: "0.0.0.0"
port: 8501
raw:
address: "0.0.0.0"
port: 8502
http:
address: "0.0.0.0"
port: 8503
auth:
secret: "bMa3mU4oCsX2KBex5o7GzwSnACpumFq3SdlDXYZgVTU="
expire: 259200