config

package
v0.0.0-...-16a29c9 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

Initialize the configuration

Types

type App

type App struct {
	// The name of the application
	Name string `json:"name"`
	// The path to the data directory
	// This is where exposed files are stored
	DataDir string `json:"data_dir"`
	// The path to the working directory
	// This is where the application variables are stored like the database
	WorkDir string `json:"work_dir"`
	// The debuging mode
	Debug bool `json:"debug"`
}

type CLI

type CLI struct {
	Port       string
	Host       string
	WorkDir    string
	DataDir    string
	ConfigFile string
	Debug      bool
}

CLI struct is to store the command line arguments values

type Cert

type Cert struct {
	// For enabling automatic certificate, delivered by Let's Encrypt
	// Require the Config.Server.Domain to be set and valid
	Auto bool `json:"auto"`

	// Certificate file path are uncompatible with the auto option
	// The path to the certificate
	Crt string `json:"crt"`
	// The path to the certificate key
	Key string `json:"key"`
}

type Config

type Config struct {
	// Server configuration
	Server Server `json:"server"`
	// App configuration
	App App `json:"app"`
	// UI configuration
	UI UI `json:"ui"`

	// OS store the os information
	OS OS `json:"-"`
	// The Config file path
	ConfigFile string `json:"-"`
}
var Data Config

Data is the global configuration

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults set the default configuration values

func (*Config) SetFromCLI

func (c *Config) SetFromCLI()

SeteFromCLI set the configuration values with the command line flags

func (*Config) SetFromEnv

func (c *Config) SetFromEnv()

SetFromEnv set the configuration values from the environment variables

func (*Config) SetFromFile

func (c *Config) SetFromFile() error

SetFromFile set the configuration values from a json file If the file does not exist, it will be created with the default values

type Meta

type Meta struct {
	// The author of the application
	Author string `json:"author"`
	// The description of the application
	Description string `json:"description"`
	// The title prefix of the application
	TitlePrefix string `json:"title_prefix"`
}

type OS

type OS struct {
	// PID of the process
	PID int
	// GID of app user
	GID int
	// UID of app user
	UID int
}

type Server

type Server struct {
	// The port of the server
	Port string `json:"port"`
	// The host of the server
	Host string `json:"host"`
	// A valid domain name for the server
	Domain string `json:"domain"`
	// The compression level of server responses
	Compression int `json:"compression"`
	// The maximum body size of a request
	MaxBodySize int `json:"max_body_size"`

	// The certificate for the server
	Cert Cert `json:"cert"`
}

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the address of the server

type UI

type UI struct {
	// The application meta information
	Meta Meta `json:"meta"`
}

Jump to

Keyboard shortcuts

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