Documentation
¶
Index ¶
- type CachedFile
- type FileHandler
- func (h *FileHandler) ClearCache()
- func (h *FileHandler) GetCacheItemCount() int64
- func (h *FileHandler) GetCacheSize() int64
- func (h *FileHandler) GetStats() *monitoring.Stats
- func (h *FileHandler) ServeFile(fileName string, content []byte) *FileResponse
- func (h *FileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type FileHandlerOptions
- type FileResponse
- type HandlerStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedFile ¶
type CachedFile struct {
Content []byte
CompressedContent []byte
ContentType string
LastModified time.Time
ETag string
Expiration time.Time
}
CachedFile represents a cached static file
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler handles static file serving with memory optimization
func NewFileHandler ¶
func NewFileHandler(options *FileHandlerOptions) *FileHandler
NewFileHandler creates a new static file handler
func (*FileHandler) ClearCache ¶
func (h *FileHandler) ClearCache()
ClearCache clears the file cache
func (*FileHandler) GetCacheItemCount ¶
func (h *FileHandler) GetCacheItemCount() int64
GetCacheItemCount returns the number of items in the cache
func (*FileHandler) GetCacheSize ¶
func (h *FileHandler) GetCacheSize() int64
GetCacheSize returns the current cache size in bytes
func (*FileHandler) GetStats ¶
func (h *FileHandler) GetStats() *monitoring.Stats
GetStats returns statistics for the file handler
func (*FileHandler) ServeFile ¶
func (h *FileHandler) ServeFile(fileName string, content []byte) *FileResponse
ServeFile serves a file with the given name and content This method is primarily for benchmarking and testing
func (*FileHandler) ServeHTTP ¶
func (h *FileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface
type FileHandlerOptions ¶
type FileHandlerOptions struct {
// Root directory for static files
RootDir string
// Whether to enable file caching
EnableCache bool
// Maximum cache size in bytes
MaxCacheSize int64
// Whether to enable gzip compression
EnableCompression bool
// Minimum file size for compression in bytes
MinCompressSize int64
// Cache expiration time
CacheExpiration time.Duration
// File extensions to compress
CompressExtensions []string
}
FileHandlerOptions contains options for the static file handler
func DefaultFileHandlerOptions ¶
func DefaultFileHandlerOptions() *FileHandlerOptions
DefaultFileHandlerOptions returns default options for the file handler
func LoadFromConfig ¶
func LoadFromConfig(cfg *config.MemoryConfig) *FileHandlerOptions
LoadFromConfig loads file handler options from configuration