config

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZEPTO_TEST_CONFIG = Config{
	App: AppConfig{
		Name:    "zepto-test",
		Version: "1.0.0",
		Session: SessionConfig{
			Name:   "zsid",
			Secret: "test",
		},
	},
	Server: ServerConfig{
		Host:         "0.0.0.0",
		Port:         8000,
		ReadTimeout:  15000,
		WriteTimeout: 15000,
	},
	Logger: LoggerConfig{
		Level:     "error",
		Colors:    true,
		Timestamp: true,
	},
}

Functions

func SetDefaults

func SetDefaults()

Types

type AppConfig

type AppConfig struct {
	// App Name (e.g. my-project) [required]
	Name string `json:"name" mapstructure:"name"`

	// App Version (e.g. "1.0.0")
	Version string `json:"version" mapstructure:"version"`

	// App Session
	Session SessionConfig `json:"session" mapstructure:"session"`

	// App Webpack Enabled [default: true]
	WebpackEnabled bool `json:"webpack_enabled" mapstructure:"webpack_enabled"`
}

App Config is the configuration for the Zepto App

type Config

type Config struct {
	App    AppConfig    `json:"app" mapstructure:"app"`
	Server ServerConfig `json:"server" mapstructure:"server"`
	Logger LoggerConfig `json:"logger" mapstructure:"logger"`
	DB     DBConfig     `json:"db" mapstructure:"db"`
}

func NewConfigFromFile

func NewConfigFromFile() (*Config, error)

type DBConfig

type DBConfig struct {
	// Enabled
	//
	// default: true
	Enabled bool `json:"enabled" mapstructure:"enabled"`

	// Adapter (e.g. "postgres", "sqlite", "mysql")
	//
	// default: "sqlite"
	Adapter string `json:"adapter" mapstructure:"adapter"`

	// DB Host (e.g. "127.0.0.1")
	Host string `json:"host" mapstructure:"host"`

	// DB Port (e.g. 5432)
	Port int `json:"port" mapstructure:"port"`

	// DB Username
	Username string `json:"username" mapstructure:"username"`

	// DB Password
	Password string `json:"password" mapstructure:"password"`

	// DB Database
	//
	// default: "db/development.sqlite3"
	Database string `json:"database" mapstructure:"database"`

	// DB SSLMode
	//
	// default: ""
	SSLMode string `json:"sslmode" mapstructure:"sslmode"`
}

DBConfig is the configuration for the database.

You can change the database instance, but this configuration will be ignored

type LoggerConfig

type LoggerConfig struct {
	// Level (e.g. "trace", "debug", "info", "warning", "error", "fatal", "panic")
	//
	// default: "debug"
	Level string `json:"level" mapstructure:"level"`

	// Enable colored log
	//
	// default: true
	Colors bool `json:"colors" mapstructure:"colors"`

	// Show timestamp in log
	//
	// default: true
	Timestamp bool `json:"timestamp" mapstructure:"timestamp"`
}

LoggerConfig is the configuration for the default logger.

You can change the logger instance, but this configuration will be ignored

type ServerConfig

type ServerConfig struct {
	// Server Host (e.g. localhost)
	Host string `json:"host" mapstructure:"host"`

	// Server Port (0 to 65535)
	Port int `json:"port" mapstructure:"port"`

	// Server read timeout (ms)
	ReadTimeout int `json:"read_timeout" mapstructure:"read_timeout"`

	// Server write timeout (ms)
	WriteTimeout int `json:"write_timeout" mapstructure:"write_timeout"`
}

ServerConfig is the configuration for the default server.

You can change the server instance (*http.Server), but this configuration will be ignored

type SessionConfig

type SessionConfig struct {
	// Session Name [default="zsid"]
	Name string `json:"name" mapstructure:"name"`

	// Unique protected string used to hash session [required]
	Secret string `json:"secret" mapstructure:"secret"`

	SameSite string `json:"same_site" mapstructure:"same_site"`
}

SessionConfig is the configuration for the default session.

You can change the session provider, but this configuration will be ignored

Jump to

Keyboard shortcuts

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