static

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StaticConfig

type StaticConfig struct {
	// AssetsDir is the subdirectory within the embedded FS (e.g., "assets", "dist")
	AssetsDir string
	// SPAMode enables Single Page Application routing (serves index.html for non-file routes)
	SPAMode bool
	// DevMode disables static serving (for development when using dev server)
	DevMode bool
	// APIPrefix excludes paths starting with this prefix from static serving
	APIPrefix string
}

StaticConfig configures static file serving behavior

type StaticResponse

type StaticResponse struct {
	StatusCode   int
	ContentType  string
	CacheControl string
	Body         []byte
	NotFound     bool
}

StaticResponse contains the result of static file processing

func ServeStaticFile

func ServeStaticFile(assets embed.FS, config StaticConfig, path string) StaticResponse

ServeStaticFile is the core logic for serving static files, router-agnostic

Jump to

Keyboard shortcuts

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