config

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket added in v0.0.26

type Bucket struct {
	Class   *string `json:"class,omitempty"`
	Stream  *bool   `json:"stream,omitempty"`
	Oneshot *bool   `json:"oneshot,omitempty"`

	Template *Template `json:"template,omitempty"`
}

type Config

type Config struct {
	Http        Http              `json:"http"`
	Paste       Paste             `json:"paste"`
	LandingPage LandingPage       `json:"landing_page"`
	Endpoints   Endpoints         `json:"endpoints"`
	Storage     Storage           `json:"storage"`
	Buckets     map[string]Bucket `json:"buckets"`
}

type Endpoints

type Endpoints struct {
	ExposeVersion bool `json:"expose_version" default:"false"`
	ExposeList    bool `json:"expose_list" default:"false"`
}

type Expiration

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

type Http

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

type LandingPage

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

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

	ContentType string `json:"content_type" 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  `json:"mime" required:"true"`
	Regex *Regexp `json:"regex" required:"true"`
}

type Paste

type Paste struct {
	RandomUrl RandomUrl `json:"random_url" `

	HandleSpaces  string         `json:"handle_spaces" default:"replace"`
	DefaultExt    string         `json:"default_extension" default:"txt"`
	Expiration    Expiration     `json:"expiration"`
	MimeOverride  []MimeOverride `json:"mime_override"`
	MimeBlacklist []string       `json:"mime_blacklist"`
}

type RandomUrl

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

	Length int `default:"8" json:"length"` // for alphanumeric

	Words     int    `default:"2" json:"words"`     // for petname
	Separator string `default:"-" json:"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 `json:"storage_path" default:"./upload"`
	DeduplicateUploads bool   `json:"deduplicate_uploads" default:"false"`
}

type Template added in v0.0.26

type Template struct {
	Parsed *template.Template
}

func (*Template) UnmarshalJSON added in v0.0.26

func (t *Template) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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