settings

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cfg parses and validates the configuration

Index

Constants

View Source
const (
	Username = iota
	EMail
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowedFileExts added in v0.3.1

type AllowedFileExts map[string]string

func (*AllowedFileExts) Unmarshal added in v0.3.1

func (afe *AllowedFileExts) Unmarshal(value string) error

type Application

type Application struct {
	Title        string `cfg:"application_title"`
	Language     string `cfg:"application_language"`
	Description  string `cfg:"application_description"`
	Domain       string `cfg:"application_domain"`
	Favicon      string `cfg:"application_favicon" default:"assets/favicon.ico"`
	RobotsTxt    string `cfg:"application_robots_txt"`
	CustomCSS    string `cfg:"application_custom_css"`
	OverwriteCSS bool   `cfg:"application_overwrite_default_css" default:"false"`
}

type Blog

type Blog struct {
	ArticlesPerPage int `cfg:"blog_articles_per_page" default:"20"`
	RSSFeedItems    int `cfg:"blog_rss_feed_items" default:"10"`
}

type CSRF

type CSRF struct {
	CookieName   string `cfg:"csrf_cookie_name" default:"csrf"`
	CookieSecure bool   `cfg:"csrf_cookie_secure" default:"true"`
	CookiePath   string `cfg:"csrf_cookie_path" default:"/admin"`
	RandomKey    string `cfg:"csrf_random_key"`
}

type Database

type Database struct {
	File string `cfg:"sqlite_file" default:"data/goblog.sqlite"`
}

type File

type File struct {
	Location              string          `cfg:"file_location" default:"/srv/goblog/files/"`
	MaxUploadSize         cfg.FileSize    `cfg:"file_max_upload_size" default:"10MB"`
	AllowedFileExtensions AllowedFileExts `cfg:"file_allowed_extensions"`
}

type Log

type Log struct {
	Level      string `cfg:"log_level" default:"info"`
	File       string `cfg:"log_file" default:"/var/log/goblog/error.log"`
	Access     bool   `cfg:"log_access" default:"true"`
	AccessFile string `cfg:"log_access_file" default:"/var/log/goblog/access.log"`
}

type LoginMethod

type LoginMethod int

func (*LoginMethod) Unmarshal

func (lm *LoginMethod) Unmarshal(value string) error

type Mail

type Mail struct {
	Host     string `cfg:"mail_smtp_host" default:"127.0.0.1"`
	Port     int    `cfg:"mail_smtp_port" default:"25"`
	User     string `cfg:"mail_smtp_user"`
	Password string `cfg:"mail_smtp_password"`

	SenderAddress string `cfg:"mail_sender_address"`
	SubjectPrefix string `cfg:"mail_subject_prefix"`
}

type Server

type Server struct {
	Address string `cfg:"server_address" default:"127.0.0.1"`
	Port    int    `cfg:"server_port" default:"4730"`

	UseTLS bool   `cfg:"use_tls" default:"yes"`
	Cert   string `cfg:"ssl_certificate_file"`
	Key    string `cfg:"ssl_certificate_key_file"`
}

type Session

type Session struct {
	TTL               time.Duration `cfg:"session_time_to_live" default:"2h"`
	GarbageCollection time.Duration `cfg:"session_garbage_collection" default:"5m"`
	CookieName        string        `cfg:"session_cookie_name" default:"goblog"`
	CookieSecure      bool          `cfg:"session_cookie_secure" default:"true"`
	CookiePath        string        `cfg:"session_cookie_path" default:"/admin"`
}

type Settings

type Settings struct {
	Environment  string `cfg:"environment" default:"prod"`
	BuildVersion string `cfg:"-"`
	BuildGitHash string `cfg:"-"`

	Application
	Blog
	User
	File
	Server
	Database
	Mail
	Session
	CSRF
	Log
}

func LoadConfig

func LoadConfig(filename string) (*Settings, error)

func MergeConfigs

func MergeConfigs(configs []cfg.File) (*Settings, error)

func (*Settings) CheckConfig

func (cfg *Settings) CheckConfig() error

func (*Settings) GenerateCSRF

func (cfg *Settings) GenerateCSRF() (bool, error)

type User

type User struct {
	MinPasswordLength int         `cfg:"user_min_password_length" default:"12"`
	InterceptorPlugin string      `cfg:"user_interceptor_plugin"`
	LoginMethod       LoginMethod `cfg:"user_login_method" default:"username"`
}

Jump to

Keyboard shortcuts

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