config

package
v0.7.56 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const SuperCode = "686868"

For testing

Variables

View Source
var BrandDomainName = "dizkaz.com"
View Source
var BrandName = "笛卡"

var BrandName = "DizKaz"

View Source
var ReplyDepthPageSize = 10
View Source
var Slogan = ""

Functions

func Init

func Init(envFile string) error

func InitFromEnv

func InitFromEnv() error

Types

type AppConfig

type AppConfig struct {
	SessionSecret      string `env:"SESSION_SECRET"`
	CSRFSecret         string `env:"CSRF_SECRET"`
	DomainName         string `env:"DOMAIN_NAME" envDefault:"localhost"`
	AppPort            int    `env:"APP_PORT" envDefault:"3000"`
	AppOuterPort       int    `env:"APP_OUTER_PORT" envDefault:"3000"`
	NginxPort          int    `env:"NGINX_PORT" envDefault:"80"`
	NginxSSLPort       int    `env:"NGINX_SSL_PORT" envDefault:"443"`
	Debug              bool   `env:"DEBUG" envDefault:"false"`
	BrandName          string `env:"BRAND_NAME"`
	BrandDomainName    string `env:"BRAND_DOMAIN_NAME"`
	Slogan             string `env:"SLOGAN"`
	DB                 *DBConfig
	ReplyDepthPageSize int
	AdminEmail         string `env:"ADMIN_EMAIL"`
	Redis              *RedisConfig
	SMTP               *SMTPConfig
	Testing            bool   `env:"TEST"`
	GoogleClientID     string `env:"GOOGLE_CLIENT_ID"`
	GoogleClientSecret string `env:"GOOGLE_CLIENT_SECRET"`
	GithubClientID     string `env:"GITHUB_CLIENT_ID"`
	GithubClientSecret string `env:"GITHUB_CLIENT_SECRET"`
	CloudflareSiteKey  string `env:"CLOUDFLARE_SITE_KEY"`
	CloudflareSecret   string `env:"CLOUDFLARE_SECRET"`
}
var Config *AppConfig

func NewTest

func NewTest() (*AppConfig, error)

func Parse

func Parse(envFile string) (*AppConfig, error)

Parse env file and generate AppConfig struct

func ParseFromEnv

func ParseFromEnv() (*AppConfig, error)

func (*AppConfig) GetServerURL

func (ac *AppConfig) GetServerURL() string

type DBConfig

type DBConfig struct {
	DBHost              string `env:"DB_HOST"`
	DBName              string `env:"DB_NAME"`
	DBPort              int    `env:"DB_PORT"`
	DBUser              string `env:"DB_USER"`
	AdminPassword       string `env:"ADMIN_PASSWORD"`
	UserDefaultPassword string `env:"USER_DEFAULT_PASSWORD"`
}

func (*DBConfig) GetDSN

func (dbCfg *DBConfig) GetDSN() string

type Permission

type Permission struct {
	Name    string `yaml:"name"`
	AdaptId string `yaml:"adapt_id"`
	Enabled bool   `yaml:"enabled"`
}

type PermissionData

type PermissionData struct {
	Modules []string
	Data    PermissionMap
	// contains filtered or unexported fields
}

func ParsePermissionData

func ParsePermissionData(filePath string) (*PermissionData, error)

func (*PermissionData) DefaultData

func (pd *PermissionData) DefaultData() (*PermissionData, error)

func (*PermissionData) GetDefaultEnabledFrontIdList

func (pd *PermissionData) GetDefaultEnabledFrontIdList() []string

func (*PermissionData) GetEnabledFrontIdList

func (pd *PermissionData) GetEnabledFrontIdList(permittedIds []string, isSuper bool) []string

AdaptId is to associate with backend return permission ID, witch is for the separation of frontend and backend In frontend we only use module and action name

func (*PermissionData) GetModuleList

func (pd *PermissionData) GetModuleList() []string

func (*PermissionData) Valid

func (pd *PermissionData) Valid(module string) bool

type PermissionMap

type PermissionMap map[string]map[string]*Permission

type RedisConfig

type RedisConfig struct {
	Host     string `env:"REDIS_HOST"`
	Port     string `env:"REDIS_PORT"`
	User     string `env:"REDIS_USER"`
	Password string `env:"REDIS_PASSWORD"`
}

type RoleData

type RoleData struct {
	RoleIdList []RoleId `yaml:"role_id_list,flow"`
	Data       RoleDataMap
}

func ParseRoleData

func ParseRoleData(filePath string) (*RoleData, error)

func (RoleData) Get

func (rd RoleData) Get(roleId RoleId) *RoleItem

func (RoleData) Valid

func (rd RoleData) Valid(roleId string) bool

type RoleDataMap

type RoleDataMap map[RoleId]*RoleItem

type RoleId

type RoleId string

type RoleItem

type RoleItem struct {
	Name        string   `yaml:"name"`
	AdaptId     string   `yaml:"adapt_id"`
	Permissions []string `yaml:"permissions,flow"`
}

type RoleType

type RoleType string

type SMTPConfig

type SMTPConfig struct {
	Server     string `env:"SMTP_SERVER"`
	ServerPort string `env:"SMTP_SERVER_PORT"`
	User       string `env:"SMTP_USER"`
	Sender     string `env:"SMTP_SENDER"`
	Password   string `env:"SMTP_PASSWORD"`
}

Jump to

Keyboard shortcuts

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