server

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: LGPL-3.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() (string, error)

func LoadCfg added in v0.5.3

func LoadCfg(ctx context.Context, args *Args) (*gocfg.Cfg, error)

LoadCfg loads the default config, the config in database, config files and arguments in order. All config values will be merged into one, and the latter overwrites the former. Each config can be part of the whole ServerCfg

Types

type Args added in v0.5.7

type Args struct {
	Host    string   `short:"h" long:"host" description:"server hostname"`
	Port    int      `short:"p" long:"port" description:"server port"`
	DbPath  string   `short:"d" long:"db" description:"path of the quickshare.db"`
	Configs []string `short:"c" long:"configs" description:"config path"`
}

type Config

type Config struct {
	Fs      *FSConfig      `json:"fs" yaml:"fs"`
	Secrets *Secrets       `json:"secrets" yaml:"secrets"`
	Server  *ServerCfg     `json:"server" yaml:"server"`
	Users   *UsersCfg      `json:"users" yaml:"users"`
	Workers *WorkerPoolCfg `json:"workers" yaml:"workers"`
	Site    *db.SiteConfig `json:"site" yaml:"site"`
	Db      *DbConfig      `json:"db" yaml:"db"`
}

func DefaultConfigStruct added in v0.5.3

func DefaultConfigStruct() *Config

func NewConfig

func NewConfig() *Config

type DbConfig added in v0.5.3

type DbConfig struct {
	DbPath string `json:"dbPath" yaml:"dbPath"`
}

type FSConfig

type FSConfig struct {
	Root       string `json:"root" yaml:"root"`
	OpensLimit int    `json:"opensLimit" yaml:"opensLimit"`
	OpenTTL    int    `json:"openTTL" yaml:"openTTL"`
}

type Initer added in v0.10.1

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

func NewIniter added in v0.10.1

func NewIniter(cfg gocfg.ICfg) *Initer

func (*Initer) InitDeps added in v0.10.1

func (it *Initer) InitDeps() *depidx.Deps

func (*Initer) InitHandlers added in v0.10.1

func (it *Initer) InitHandlers(deps *depidx.Deps) (*gin.Engine, error)

type MockClient added in v0.10.1

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

type Secrets

type Secrets struct {
	TokenSecret string `json:"tokenSecret" yaml:"tokenSecret" cfg:"env"`
}

type Server

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

func NewServer

func NewServer(cfg gocfg.ICfg) (*Server, error)

func (*Server) Shutdown

func (s *Server) Shutdown() error

func (*Server) Start

func (s *Server) Start() error

type ServerCfg

type ServerCfg struct {
	Debug             bool   `json:"debug" yaml:"debug"`
	Host              string `json:"host" yaml:"host"`
	Port              int    `json:"port" yaml:"port" cfg:"env"`
	ReadTimeout       int    `json:"readTimeout" yaml:"readTimeout"`
	WriteTimeout      int    `json:"writeTimeout" yaml:"writeTimeout"`
	MaxHeaderBytes    int    `json:"maxHeaderBytes" yaml:"maxHeaderBytes"`
	PublicPath        string `json:"publicPath" yaml:"publicPath"`
	SearchResultLimit int    `json:"searchResultLimit" yaml:"searchResultLimit"`
	InitFileIndex     bool   `json:"initFileIndex" yaml:"initFileIndex"`
}

type UsersCfg

type UsersCfg struct {
	EnableAuth         bool          `json:"enableAuth" yaml:"enableAuth"`
	DefaultAdmin       string        `json:"defaultAdmin" yaml:"defaultAdmin" cfg:"env"`
	DefaultAdminPwd    string        `json:"defaultAdminPwd" yaml:"defaultAdminPwd" cfg:"env"`
	CookieTTL          int           `json:"cookieTTL" yaml:"cookieTTL"`
	CookieSecure       bool          `json:"cookieSecure" yaml:"cookieSecure"`
	CookieHttpOnly     bool          `json:"cookieHttpOnly" yaml:"cookieHttpOnly"`
	MinUserNameLen     int           `json:"minUserNameLen" yaml:"minUserNameLen"`
	MinPwdLen          int           `json:"minPwdLen" yaml:"minPwdLen"`
	CaptchaWidth       int           `json:"captchaWidth" yaml:"captchaWidth"`
	CaptchaHeight      int           `json:"captchaHeight" yaml:"captchaHeight"`
	CaptchaEnabled     bool          `json:"captchaEnabled" yaml:"captchaEnabled"`
	UploadSpeedLimit   int           `json:"uploadSpeedLimit" yaml:"uploadSpeedLimit"`
	DownloadSpeedLimit int           `json:"downloadSpeedLimit" yaml:"downloadSpeedLimit"`
	SpaceLimit         int           `json:"spaceLimit" yaml:"spaceLimit"`
	LimiterCapacity    int           `json:"limiterCapacity" yaml:"limiterCapacity"`
	LimiterCyc         int           `json:"limiterCyc" yaml:"limiterCyc"`
	PredefinedUsers    []*db.UserCfg `json:"predefinedUsers" yaml:"predefinedUsers"`
}

type WorkerPoolCfg

type WorkerPoolCfg struct {
	QueueSize   int `json:"queueSize" yaml:"queueSize"`
	SleepCyc    int `json:"sleepCyc" yaml:"sleepCyc"`
	WorkerCount int `json:"workerCount" yaml:"workerCount"`
}

Jump to

Keyboard shortcuts

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