bstore

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheMiddleware added in v0.2.21

func CacheMiddleware(cache *expirable.LRU[string, []byte]) gin.HandlerFunc

func ConfDir

func ConfDir() (string, error)

func GetCache added in v0.2.21

func GetCache(c *gin.Context) *expirable.LRU[string, []byte]

func HandleError

func HandleError(c *gin.Context, err error)

func LogDir

func LogDir() (string, error)

Types

type BstoreError

type BstoreError struct {
	Code    int
	Message string
	Err     error
}

func NewError

func NewError(code int, message string, err error) *BstoreError

func (*BstoreError) Error

func (e *BstoreError) Error() string

type CORSConfig

type CORSConfig struct {
	AllowOrigins     []string `yaml:"allow_origins"`
	AllowMethods     []string `yaml:"allow_methods"`
	AllowHeaders     []string `yaml:"allow_headers"`
	ExposeHeaders    []string `yaml:"expose_headers"`
	AllowCredentials bool     `yaml:"allow_credentials"`
	MaxAge           int      `yaml:"max_age"`
}

type CacheConfig added in v0.2.21

type CacheConfig struct {
	Enabled bool `yaml:"enable"`
	N       int  `yaml:"n_items"`
	TTL     int  `yaml:"ttl"`
}

type IPRateLimiter

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

func NewIPRateLimiter

func NewIPRateLimiter(capacity int) *IPRateLimiter

func (*IPRateLimiter) CheckRateLimit

func (rl *IPRateLimiter) CheckRateLimit(ip string, limit int64, per time.Duration) bool

type ListResponse

type ListResponse struct {
	Files   []string `json:"files"`
	Length  int      `json:"length"`
	Message string   `json:"message"`
}

type MiddlewareConfig

type MiddlewareConfig struct {
	MaxPathLength     int             `yaml:"max_path_length"`
	OnlyBstorePaths   bool            `yaml:"only_bstore_paths"`
	RateLimitCapacity int64           `yaml:"rate_limit_capacity"`
	RateLimit         RateLimitConfig `yaml:"rate_limit"`
}

type RateLimitConfig

type RateLimitConfig struct {
	Enabled     bool  `yaml:"enabled"`
	MaxRequests int64 `yaml:"max_requests"`
	Duration    int64 `yaml:"duration"`
}

type ReqValidation

type ReqValidation struct {
	Err        error
	HttpStatus int
	Fpath      string
	BasePath   string
}

type ServerCfg

type ServerCfg struct {
	Host             string           `yaml:"host"`
	Keys             string           `yaml:"keys"`
	PublicBasePath   string           `yaml:"public_base_path"`
	PrivateBasePath  string           `yaml:"private_base_path"`
	MaxFileSize      int64            `yaml:"max_file_size"`
	LogFile          string           `yaml:"log_file"`
	Encrypt          bool             `yaml:"encrypt"`
	Compress         bool             `yaml:"compress"`
	CompressionLevel int              `yaml:"compression_lvl"`
	Cache            CacheConfig      `yaml:"cache"`
	Streaming        StreamingConfig  `yaml:"streaming"`
	CORS             CORSConfig       `yaml:"cors"`
	MWare            MiddlewareConfig `yaml:"middleware"`
}

func (*ServerCfg) Cors

func (bstore *ServerCfg) Cors(r *gin.Engine)

func (*ServerCfg) Delete

func (bstore *ServerCfg) Delete(c *gin.Context)

func (*ServerCfg) Get

func (bstore *ServerCfg) Get(c *gin.Context)

func (*ServerCfg) GetAccess

func (bstore *ServerCfg) GetAccess(c *gin.Context) string

func (*ServerCfg) GetRWKey

func (bstore *ServerCfg) GetRWKey() string

func (*ServerCfg) List

func (bstore *ServerCfg) List(c *gin.Context)

func (*ServerCfg) Load

func (cfg *ServerCfg) Load(conf_file string) error

func (*ServerCfg) MakeUrl

func (bstore *ServerCfg) MakeUrl(c *gin.Context, fpath string) string

func (*ServerCfg) Middleware

func (bstore *ServerCfg) Middleware(r *gin.Engine)

func (*ServerCfg) Print

func (cfg *ServerCfg) Print()

func (*ServerCfg) Serve

func (bstore *ServerCfg) Serve() gin.HandlerFunc

func (*ServerCfg) Upload

func (bstore *ServerCfg) Upload(c *gin.Context)

func (*ServerCfg) ValidateReq

func (bstore *ServerCfg) ValidateReq(c *gin.Context) ReqValidation

type StreamResponse added in v0.2.12

type StreamResponse struct {
	Hls    string `json:"hls_url"`
	Dash   string `json:"dash_url"`
	Poster string `json:"poster_url"`
}

type StreamingConfig added in v0.2.11

type StreamingConfig struct {
	Enabled bool   `yaml:"enable"`
	Codec   string `yaml:"codec"`
	Bitrate int    `yaml:"bitrate"`
}

type UploadRespone

type UploadRespone struct {
	Url     string         `json:"url"`
	Message string         `json:"message"`
	Stream  StreamResponse `json:"stream"`
}

Jump to

Keyboard shortcuts

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