static_handler

package
v0.0.0-...-6bf6d67 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskStaticDriver

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

DiskStaticDriver 磁盘文件系统驱动实现

func NewDiskStaticDriver

func NewDiskStaticDriver(baseDir string) *DiskStaticDriver

NewDiskStaticDriver 创建磁盘驱动实例

func (*DiskStaticDriver) FileExists

func (d *DiskStaticDriver) FileExists(path string) bool

FileExists 检查文件是否存在于磁盘中

func (*DiskStaticDriver) GetDriverName

func (d *DiskStaticDriver) GetDriverName() string

GetDriverName 获取驱动名称

func (*DiskStaticDriver) GetFS

func (d *DiskStaticDriver) GetFS(dir string) (http.FileSystem, error)

GetFS 获取指定目录的文件系统

func (*DiskStaticDriver) ServeFile

func (d *DiskStaticDriver) ServeFile(c *gin.Context, dir string, relativePath string) error

ServeFile 提供文件到 gin.Context

type EmbedStaticDriver

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

EmbedStaticDriver embed.FS 驱动实现

func NewEmbedStaticDriver

func NewEmbedStaticDriver(embedFS embed.FS) *EmbedStaticDriver

NewEmbedStaticDriver 创建 embed 驱动实例

func (*EmbedStaticDriver) FileExists

func (d *EmbedStaticDriver) FileExists(path string) bool

FileExists 检查文件是否存在于 embed.FS 中

func (*EmbedStaticDriver) GetDriverName

func (d *EmbedStaticDriver) GetDriverName() string

GetDriverName 获取驱动名称

func (*EmbedStaticDriver) GetFS

func (d *EmbedStaticDriver) GetFS(dir string) (http.FileSystem, error)

GetFS 获取指定目录的文件系统

func (*EmbedStaticDriver) ServeFile

func (d *EmbedStaticDriver) ServeFile(c *gin.Context, dir string, relativePath string) error

ServeFile 提供文件到 gin.Context

type StaticFileDriver

type StaticFileDriver interface {
	// FileExists 检查文件是否存在
	FileExists(path string) bool

	// GetFS 获取文件系统(用于 gin.StaticFS)
	GetFS(dir string) (http.FileSystem, error)

	// ServeFile 直接提供文件到 gin.Context
	ServeFile(c *gin.Context, dir string, relativePath string) error

	// GetDriverName 获取驱动名称(用于日志)
	GetDriverName() string
}

StaticFileDriver 静态文件驱动接口

Source Files

  • disk_static_driver.go
  • embed_static_driver.go
  • static_file_driver.go

Jump to

Keyboard shortcuts

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