cfg

package
v0.0.0-...-2655f85 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseTpl     = "base.html"
	IndexTpl    = "index.html"
	UploadTpl   = "upload.html"
	DownloadTpl = "download.html"
	ErrorTpl    = "error.html"
)

html templates names

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server   server   `toml:"server"`
	Storage  Storage  `toml:"Storage"`
	Settings Settings `toml:"settings"`
}

Config is a main configuration structure.

func New

func New(filename string, t *TemplateEntry) (*Config, error)

New returns new configuration.

func (*Config) Addr

func (c *Config) Addr() string

Addr returns service's net address.

func (*Config) Close

func (c *Config) Close() error

Close frees resources.

func (*Config) DbPeriod

func (c *Config) DbPeriod() time.Duration

DbPeriod is gc database period in seconds.

func (*Config) GCPeriod

func (c *Config) GCPeriod() time.Duration

GCPeriod is gc period in seconds.

func (*Config) MaxFileSize

func (c *Config) MaxFileSize() int

MaxFileSize returns max file size.

func (*Config) Secret

func (c *Config) Secret(p string) string

Secret returns string with salt.

func (*Config) Shutdown

func (c *Config) Shutdown() time.Duration

Shutdown is shutdown timeout.

func (*Config) Timeout

func (c *Config) Timeout() time.Duration

Timeout is service timeout.

type Settings

type Settings struct {
	TTL      int                           `toml:"ttl"`
	Times    int                           `toml:"times"`
	Size     int                           `toml:"size"`
	Salt     string                        `toml:"salt"`
	GC       int                           `toml:"gc"`
	PassLen  int                           `toml:"passlen"`
	Shutdown int                           `toml:"shutdown"`
	Tpl      map[string]*template.Template `toml:"-"`
}

Settings is base service settings.

type Storage

type Storage struct {
	File    string `toml:"file"`
	Dir     string `toml:"dir"`
	Timeout int    `toml:"timeout"`
	Size    int64  `toml:"size"`

	Db *sql.DB
	// contains filtered or unexported fields
}

Storage is storage configuration params struct.

func (*Storage) Limit

func (s *Storage) Limit(v int64) error

Limit updates storage limit and returns and error if it's reached.

func (*Storage) String

func (s *Storage) String() string

String returns base info about Storage.

type TemplateEntry

type TemplateEntry struct {
	Dir string
	Fs  embed.FS
}

TemplateEntry is a struct to handle embeded templates parsing.

func (*TemplateEntry) Parse

func (t *TemplateEntry) Parse(name string) (*template.Template, error)

Parse creates a html template.

Jump to

Keyboard shortcuts

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