serve

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSelfSignedCert

func GenerateSelfSignedCert() (tls.Certificate, error)

GenerateSelfSignedCert creates an in-memory ECDSA P-256 self-signed TLS certificate.

func LoadDirectoryTemplate

func LoadDirectoryTemplate() (*template.Template, error)

LoadDirectoryTemplate loads the HTML template for directory listings.

func Run

func Run(opts ...Option) error

Run starts the HTTP/HTTPS file server.

Types

type Config

type Config struct {
	Addr       string
	Dir        string
	EnableGzip bool
	EnableTLS  bool
}

Config holds configuration for the serve command.

type DirEntry

type DirEntry struct {
	Name    string
	Link    string
	Size    string
	ModTime string
	IsDir   bool
}

DirEntry represents a directory listing entry.

type Option

type Option func(*Config)

Option configures a Config.

func WithAddr

func WithAddr(addr string) Option

func WithDir

func WithDir(dir string) Option

func WithGzip

func WithGzip(enable bool) Option

func WithTLS

func WithTLS(enable bool) Option

Jump to

Keyboard shortcuts

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