config

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Log: Log{
		Level:      "debug",
		Dir:        "./logs",
		FileFormat: "2006-01-02.log",
	},
	Server: Server{
		Address: ":3000",
		Header:  "CatSync",
	},
	Actions: []Action{
		{
			Route:      "/",
			Action:     action.String,
			ActionData: "Hello from CatSync!",
		},
		{
			Route:  "/json",
			Action: action.JSON,
			ActionData: fiber.Map{
				"msg": "Hello from CatSync!",
				"data": fiber.Map{
					"version": version.GetFormatVersion(),
				},
			},
		},
	},
}
View Source
var ErrConfigNotFound = errors.New("config file not found")
View Source
var Path string

Functions

This section is empty.

Types

type Action

type Action struct {
	Route          string      `json:"route"          yaml:"route"`
	Action         action.Type `json:"action"         yaml:"action"`
	ActionData     action.Data `json:"actionData"     yaml:"actionData"`
	ResponseHeader http.Header `json:"responseHeader" optional:"true"   yaml:"responseHeader"`
	Auth           ActionAuth  `json:"auth"           optional:"true"   yaml:"auth"`
}

type ActionAuth

type ActionAuth struct {
	UA    string          `json:"ua"    optional:"true" yaml:"ua"`
	Query ActionAuthQuery `json:"query" optional:"true" yaml:"query"`
}

type ActionAuthQuery

type ActionAuthQuery struct {
	Map            map[string]string `json:"map"            yaml:"map"`
	IgnoreCaseCase bool              `json:"ignoreCaseCase" optional:"true" yaml:"ignoreCaseCase"`
}

type Config

type Config struct {
	Log     Log      `json:"log"     yaml:"log"`
	Server  Server   `json:"server"  yaml:"server"`
	Actions []Action `json:"actions" optional:"true" yaml:"actions"`
}

func New added in v1.6.0

func New(loaders ...Loader) (*Config, error)

func (*Config) Merge added in v1.6.0

func (c *Config) Merge(src *Config)

func (*Config) Validate added in v1.6.0

func (c *Config) Validate(tag string) error

type Loader

type Loader interface {
	GetTag() string
	Load(cfg *Config, fileName string) error
	Save(cfg *Config, fileName string) error
	// GetAllowFileExtensions lowercase
	GetAllowFileExtensions() []string
}

type Log

type Log struct {
	Dir        string `json:"dir"        optional:"true"   yaml:"dir"`
	Level      string `json:"level"      optional:"true"   yaml:"level"`
	FileFormat string `json:"fileFormat" yaml:"fileFormat"`
}

type Server

type Server struct {
	Address string    `json:"address" yaml:"address"`
	Header  string    `json:"header"  optional:"true" yaml:"header"`
	TLS     ServerTLS `json:"tls"     optional:"true" yaml:"tls"`
}

type ServerTLS

type ServerTLS struct {
	Cert string `json:"cert" yaml:"cert"`
	Key  string `json:"key"  yaml:"key"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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