config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindConfigToContext

func BindConfigToContext(ctx context.Context) context.Context

BindConfigToContext binds the configuration to the context.

func Reload

func Reload() error

Reload reloads the configuration from the file.

func Watch

func Watch(callback func(*Config))

Watch watches the configuration file and reloads it when it changes.

Types

type Auth

type Auth struct {
	JWT       *JWT
	Casbin    *Casbin
	Whitelist []string
}

Auth auth config struct

type Casbin

type Casbin struct {
	Path  string
	Model string
}

Casbin casbin config struct

type Config

type Config struct {
	AppName   string
	RunMode   string
	Protocol  string
	Domain    string
	Host      string
	Port      int
	Consul    *Consul
	Observes  *Observes
	Extension *Extension
	Frontend  *Frontend
	Logger    *Logger
	Data      *Data
	Auth      *Auth
	Storage   *Storage
	OAuth     *OAuth
	Email     *Email
	Viper     *viper.Viper
}

Config represents the configuration implementation.

func GetConfig

func GetConfig() (*Config, error)

GetConfig returns the configuration. It does not handle errors internally; instead, it returns the error for the caller to handle.

func Init

func Init() (cfg *Config, err error)

Init initializes and loads the configuration.

func LoadConfig

func LoadConfig(configPath string) (*Config, error)

LoadConfig loads the configuration from the file.

type Consul

type Consul struct {
	Address   string `json:"address"`
	Scheme    string `json:"scheme"`
	Discovery struct {
		DefaultTags   []string          `json:"default_tags"`
		DefaultMeta   map[string]string `json:"default_meta"`
		HealthCheck   bool              `json:"health_check"`
		CheckInterval string            `json:"check_interval"`
		Timeout       string            `json:"timeout"`
	} `json:"discovery"`
}

Consul config struct

type DBNode

type DBNode = dc.DBNode

DBNode represents a database node

type Data

type Data = dc.Config

Data represents the data configuration

type Email

type Email = email.Email

Email represents the email configuration

type Extension

type Extension struct {
	Mode      string
	Path      string
	Includes  []string
	Excludes  []string
	HotReload bool
}

Extension extension config struct

type Facebook

type Facebook struct {
	ID     string
	Secret string
}

Facebook facebook config struct

type Frontend

type Frontend struct {
	SignInURL string
	SignUpURL string
}

Frontend frontend config struct

type Github

type Github struct {
	ID     string
	Secret string
}

Github github config struct

type Google

type Google struct {
	ID     string
	Secret string
}

Google google config struct

type JWT

type JWT struct {
	Secret string
	Expire int
}

JWT jwt config struct

type Logger

type Logger struct {
	Level         int
	Path          string
	Format        string
	Output        string
	OutputFile    string
	IndexName     string
	Meilisearch   *dc.Meilisearch
	Elasticsearch *dc.Elasticsearch
}

Logger logger config struct

type OAuth

type OAuth struct {
	Github   *Github
	Facebook *Facebook
	Google   *Google
}

OAuth oauth config struct

type Observes

type Observes struct {
	Sentry *Sentry
	Tracer *Tracer
}

Observes config struct

type Sentry

type Sentry struct {
	Endpoint string
}

Sentry config struct

type Storage

type Storage = storage.Config

Storage represents the storage configuration

type Tracer

type Tracer struct {
	Endpoint string
}

Tracer config struct

Jump to

Keyboard shortcuts

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