Help us shape the future of Go! Take the 2026 Go Developer Survey

settings

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyBannerText      = "banner_text"
	KeyBannerKind      = "banner_kind"
	KeyMaintenanceMode = "maintenance_mode"
	KeyAllowSignup     = "allow_signup"
	KeyAllowedDomains  = "allowed_domains"

	KeyRateLimitPerUserPerMin = "rate_limit_per_user_per_min"
	KeyRateLimitPerIPPerMin   = "rate_limit_per_ip_per_min"
	KeyRateLimitAllowlist     = "rate_limit_allowlist"
	KindInfo, KindWarn        = "info", "warn"
	FlagOff, FlagOn           = "0", "1"
)

Variables

View Source
var Descriptions = map[string]string{
	KeyBannerText:             "站点公告文本(空 = 无公告);保存后全站顶条即时生效",
	KeyBannerKind:             "公告样式:info = 蓝系 / warn = 橙红系",
	KeyMaintenanceMode:        "维护模式:开启后全站顶栏显示「维护中」条(仅提示,不阻断请求)",
	KeyAllowSignup:            "注册开关:关闭 = 邀请制(仅白名单邮箱可注册);保存后即时生效(SignupGate 热读)",
	KeyAllowedDomains:         "注册邮箱域名白名单,逗号分隔(空 = 不限域名)",
	KeyRateLimitPerUserPerMin: "API 每用户限流(请求/分钟):0 = 关闭;修改后重启生效(启动期静态注入,不热重载)",
	KeyRateLimitPerIPPerMin:   "认证路径每客户端 IP 限流(请求/分钟):0 = 关闭;修改后重启生效",
	KeyRateLimitAllowlist:     "限流豁免名单:逗号分隔 IP 或 CIDR(如 10.0.0.5, 192.168.0.0/16);修改后重启生效",
}

Functions

func Normalize

func Normalize(key, value string) string

func SplitDomains

func SplitDomains(csv string) []string

func SplitIPAllowlist

func SplitIPAllowlist(csv string) []string

func Validate

func Validate(key, value string) error

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Bootstrap

func Bootstrap(pool *pgxpool.Pool, envLookup func(string) string) (*Store, error)

func NewStore

func NewStore(pool *pgxpool.Pool) *Store

func (*Store) All

func (s *Store) All(ctx context.Context) (map[string]string, error)

func (*Store) Effective

func (s *Store) Effective(ctx context.Context) (map[string]string, error)

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (value string, found bool, err error)

func (*Store) Maintenance

func (s *Store) Maintenance(ctx context.Context) (bool, error)

func (*Store) RateLimits

func (s *Store) RateLimits(ctx context.Context) (perUser, perIP int, allowlist []string, err error)

func (*Store) RegistrationGate

func (s *Store) RegistrationGate(ctx context.Context) (allow bool, domains []string, err error)

func (*Store) Set

func (s *Store) Set(ctx context.Context, key, value, actor string) error

Directories

Path Synopsis
adapters

Jump to

Keyboard shortcuts

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