config

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Http        Http        `yaml:"http" env-default:""`
	Paste       Paste       `yaml:"paste" env-default:""`
	LandingPage LandingPage `yaml:"landing_page" env-default:""`
	Endpoints   Endpoints   `yaml:"endpoints" env-default:""`
	Storage     Storage     `yaml:"storage" env-default:""`
}

type Endpoints

type Endpoints struct {
	ExposeVersion bool `yaml:"expose_version" env-default:"false"`
	ExposeList    bool `yaml:"expose_list" env-default:"false"`
}

type Expiration

type Expiration struct {
	Enabled       bool          `env-default:"false" yaml:"enabled"`
	Interval      time.Duration `env-default:"1h" yaml:"interval"`
	DefaultExpiry time.Duration `env-default:"0s" yaml:"default_expiry"` // 0s means no expiration
}

type Http

type Http struct {
	ServerUrl        string            `yaml:"url" env-default:"http://localhost:3000"`
	Bind             string            `yaml:"bind" env-default:"127.0.0.1:3000"`
	MaxContentLength bytesize.ByteSize `yaml:"max_content_length" env-default:"10MB"`
	Timeout          time.Duration     `yaml:"timeout" env-default:"30s"`
	Auth             struct {
		WriteTokens  []string `yaml:"write_tokens"`
		DeleteTokens []string `yaml:"delete_tokens"`
	} `yaml:"auth"`
}

type LandingPage

type LandingPage struct {
	// listed in order of priority if set
	// note that all arguments support `go templates`
	File   string `yaml:"file" env-default:""`
	Text   string `yaml:"text" env-default:""`
	Preset string `yaml:"preset" env-default:"default"`

	Parameters map[string]any `yaml:"parameters"`

	ContentType string `yaml:"content_type" env-default:"text/plain; charset=utf-8"`
}

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig() (*Loader, error)

func (*Loader) C

func (o *Loader) C() *Config

func (*Loader) Config

func (o *Loader) Config() *Config

type MimeOverride

type MimeOverride struct {
	Mime  string  `yaml:"mime" required:"true"`
	Regex *Regexp `yaml:"regex" required:"true"`
}

type Paste

type Paste struct {
	RandomUrl RandomUrl `yaml:"random_url" env-default:""`

	HandleSpaces  string         `yaml:"handle_spaces" env-default:"replace"`
	DefaultExt    string         `yaml:"default_ext" env-default:".txt"`
	Expiration    Expiration     `yaml:"expiration" env-default:""`
	MimeOverride  []MimeOverride `yaml:"mime_override"`
	MimeBlacklist []string       `yaml:"mime_blacklist"`
}

type RandomUrl

type RandomUrl struct {
	Type       string `env-default:"sqid" yaml:"type"` // types xid,alphanumeric,petname
	SuffixMode bool   `yaml:"suffix_mode" default:"false"`

	Length int `env-default:"8" yaml:"length"` // for alphanumeric

	Words     int    `env-default:"2" yaml:"words"`     // for petname
	Separator string `env-default:"-" yaml:"separator"` // for petname
}

type Regexp

type Regexp struct {
	*regexp.Regexp
}

Regexp adds unmarshalling from json for regexp.Regexp

func (*Regexp) MarshalText

func (r *Regexp) MarshalText() ([]byte, error)

MarshalText marshals regexp.Regexp as string

func (*Regexp) UnmarshalJSON

func (r *Regexp) UnmarshalJSON(xs []byte) error

func (*Regexp) UnmarshalText

func (r *Regexp) UnmarshalText(b []byte) error

UnmarshalText unmarshals json into a regexp.Regexp

type Storage

type Storage struct {
	StoragePath        string `yaml:"storage_path" env-default:"./upload"`
	DeduplicateUploads bool   `yaml:"deduplicate_uploads" env-default:"false"`
}

Jump to

Keyboard shortcuts

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