config

package
v1.0.22 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	AppID     string `yaml:"appId"`
	AppName   string `yaml:"appName"`
	AppSecret string `yaml:"appSecret"`
}

App 应用配置(SDK 上报用)

type Config

type Config struct {
	Port         string
	DBPath       string
	RateLimit    int
	NonceTTL     int
	TimestampTTL int
	JWT          JWT
	Apps         []App
	Users        []User
	Events       []EventConfig // 自定义事件配置(白名单)
}

Config 服务器配置

func Load

func Load() (*Config, error)

Load 加载配置(环境变量 > config.yaml > 默认值)

func (*Config) GetEventConfig

func (c *Config) GetEventConfig(eventName string) (EventConfig, bool)

GetEventConfig 获取事件配置

func (*Config) GetSecret

func (c *Config) GetSecret(appID string) (string, bool)

GetSecret 根据 AppID 获取 Secret

func (*Config) GetUser

func (c *Config) GetUser(username string) (User, bool)

GetUser 根据用户名获取用户

func (*Config) IsEventAllowed

func (c *Config) IsEventAllowed(eventName string) bool

IsEventAllowed 检查事件是否在白名单中

type EventConfig

type EventConfig struct {
	EventName     string `yaml:"eventName"`
	Description   string `yaml:"description"`
	RetentionDays int    `yaml:"retentionDays"` // 数据保留天数(0=永久保留)
}

EventConfig 事件配置(白名单)

type JWT

type JWT struct {
	Secret      string `yaml:"secret"`
	ExpireHours int    `yaml:"expireHours"`
}

JWT JWT 配置

type User

type User struct {
	Username     string `yaml:"username"`
	PasswordHash string `yaml:"passwordHash"`
}

User 用户配置(Dashboard 登录用)

func (*User) VerifyPassword

func (u *User) VerifyPassword(password string) bool

VerifyPassword 验证密码

Jump to

Keyboard shortcuts

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