base

package
v0.0.0-...-f856fe1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RateLimitActionWait   = "wait"
	RateLimitActionReturn = "return"
)

Variables

This section is empty.

Functions

func CacheFS

func CacheFS(fs driver.FS, opt *CacheOption) (driver.FS, error)

func CompressFS

func CompressFS(fs driver.FS, opt *CompressOption) (driver.FS, error)

func EncryptFS

func EncryptFS(fs driver.FS, opt *EncryptOption) (driver.FS, error)

func HookFS

func HookFS(fs driver.FS, opt *HookOption) driver.FS

func Included

func Included(file driver.File, types []string) bool

func New

func New(fs driver.FS, opt *Option) (driver.FS, error)

func PrefixFS

func PrefixFS(fs driver.FS, prefix string) driver.FS

func RateLimitFS

func RateLimitFS(fs driver.FS, opt *RateLimitOption) (driver.FS, error)

访问频率限制

func RecycleFS

func RecycleFS(fs driver.FS, opt *RecycleOption) (driver.FS, error)

func TrimPrefixFS

func TrimPrefixFS(fs driver.FS, prefix string) driver.FS

func WrapFS

func WrapFS(fs driver.FS, opts ...WrapOption) (newFS driver.FS, err error)

Types

type CacheOption

type CacheOption struct {
	ExpireTime time.Duration `json:"expire_time"`
}

func (*CacheOption) NewFS

func (opt *CacheOption) NewFS(fs driver.FS) (driver.FS, error)

type CompressOption

type CompressOption struct {
	Level int `json:"level"`
}

func (*CompressOption) NewFS

func (opt *CompressOption) NewFS(fs driver.FS) (driver.FS, error)

type EncryptOption

type EncryptOption struct {
	Mode         string `json:"mode"`
	DirName      bool   `json:"dir_name"`
	FileName     bool   `json:"file_name"`
	Suffix       string `json:"suffix"`
	Password     string `json:"password"`
	PasswordSalt string `json:"password_salt"`
	Version      string `json:"version"`
}

func (*EncryptOption) NewFS

func (opt *EncryptOption) NewFS(fs driver.FS) (driver.FS, error)

type HookOption

type HookOption struct {
	PathFn func(string) string
	FileFn func(driver.File) (driver.File, bool)
}

func (*HookOption) NewFS

func (opt *HookOption) NewFS(fs driver.FS) (driver.FS, error)

type Option

type Option struct {
	RootPath        string          `json:"root_path"   validate:"omitempty,startswith=/"`
	HiddenFiles     []string        `json:"hidden_files"`
	Encrypt         bool            `json:"encrypt"`
	EncryptOption   EncryptOption   `json:"encrypt_option"`
	Compress        bool            `json:"compress"`
	CompressOption  CompressOption  `json:"compress_option"`
	Recycle         bool            `json:"recycle"`
	RecycleOption   RecycleOption   `json:"recycle_option"`
	Cache           bool            `json:"cache"`
	CacheOption     CacheOption     `json:"cache_option"`
	RateLimit       bool            `json:"rate_limit"`
	RateLimitOption RateLimitOption `json:"rate_limit_option"`
}

func (*Option) NewFS

func (opt *Option) NewFS(fs driver.FS) (driver.FS, error)

type RateLimitOption

type RateLimitOption struct {
	Wait  bool          `json:"wait"`
	Burst int           `json:"burst"`
	Limit time.Duration `json:"limit"`
}

func (*RateLimitOption) NewFS

func (opt *RateLimitOption) NewFS(fs driver.FS) (driver.FS, error)

type RecycleOption

type RecycleOption struct {
	Path string `json:"path" validate:"omitempty,startswith=/"`
}

func (*RecycleOption) NewFS

func (opt *RecycleOption) NewFS(fs driver.FS) (driver.FS, error)

type WrapOption

type WrapOption interface {
	NewFS(driver.FS) (driver.FS, error)
}

type WrapReader

type WrapReader struct {
	driver.FileReader
	// contains filtered or unexported fields
}

func (*WrapReader) Read

func (r *WrapReader) Read(p []byte) (n int, err error)

type WrapWriter

type WrapWriter struct {
	driver.FileWriter
	// contains filtered or unexported fields
}

func (*WrapWriter) Close

func (w *WrapWriter) Close() error

func (*WrapWriter) Write

func (w *WrapWriter) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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