server

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddr               string        // address to listen on for HTTP server
	Theme                    string        // UI theme (light/dark)
	HideFooter               bool          // whether to hide the footer in the UI
	RootDir                  string        // root directory to serve files from
	Version                  string        // version information to display in UI
	Exclude                  []string      // patterns of files/directories to exclude
	Auth                     string        // password for basic authentication
	AuthUser                 string        // username for basic authentication (defaults to "weblist")
	SessionSecret            string        // secret key for signing session tokens
	Title                    string        // custom title for the site
	SFTPUser                 string        // username for SFTP authentication
	SFTPAddress              string        // address to listen for SFTP connections
	SFTPKeyFile              string        // path to SSH private key file
	SFTPAuthorized           string        // path to authorized_keys file for public key authentication
	BrandName                string        // company or organization name for branding
	BrandColor               string        // color for navbar
	EnableSyntaxHighlighting bool          // whether to enable syntax highlighting for code files
	CustomFooter             string        // custom footer text (can contain HTML)
	InsecureCookies          bool          // allow cookies without secure flag
	SessionTTL               time.Duration // session timeout duration
	EnableMultiSelect        bool          // enable multi-file selection and download
	RecursiveMtime           bool          // calculate directory mtime from newest nested file
	EnableUpload             bool          // enable file upload support
	UploadMaxSize            int64         // max upload size in bytes
	UploadOverwrite          bool          // allow overwriting existing files on upload
}

Config represents server configuration.

type ContentTypeInfo added in v0.17.0

type ContentTypeInfo struct {
	MIMEType   string // MIME type string for the file
	IsText     bool   // true for text-based content (plain text, code, HTML, JSON, XML)
	IsHTML     bool   // true specifically for HTML content
	IsPDF      bool   // true for PDF documents
	IsImage    bool   // true for all image formats
	IsMarkdown bool   // true for markdown files (.md, .markdown)
	IsCSV      bool   // true for CSV files (.csv)
}

ContentTypeInfo holds content type information for a file

func DetermineContentType added in v0.8.4

func DetermineContentType(filePath string) ContentTypeInfo

DetermineContentType analyzes a file to determine its content type and common format flags. It uses a multi-step detection process: 1. Checks against a predefined list of known text file extensions 2. Falls back to standard MIME type detection based on file extension 3. Defaults to text/plain if no type could be determined

This is used for deciding how to present files in the UI (view vs. download).

type FileInfo

type FileInfo struct {
	Name         string
	IsDir        bool
	Size         int64
	LastModified time.Time
	Path         string
	// contains filtered or unexported fields
}

FileInfo represents a file or directory to be displayed in the list

func (FileInfo) IsViewable added in v0.4.0

func (f FileInfo) IsViewable() bool

IsViewable checks if the file can be viewed in a browser. Returns false if content detection found binary data despite text-like extension.

func (FileInfo) SizeToString

func (f FileInfo) SizeToString() string

SizeToString converts file size to human-readable format

func (FileInfo) TimeString

func (f FileInfo) TimeString() string

TimeString formats the last modified time

func (FileInfo) TimeStringShort added in v0.14.3

func (f FileInfo) TimeStringShort() string

TimeStringShort formats the last modified time with 2-digit year for mobile

type SFTP added in v0.8.0

type SFTP struct {
	Config
	FS fs.FS
	// contains filtered or unexported fields
}

SFTP represents the SFTP server.

func (*SFTP) Run added in v0.8.0

func (s *SFTP) Run(ctx context.Context) error

Run starts the SFTP server.

type Web

type Web struct {
	Config
	FS fs.FS
	// contains filtered or unexported fields
}

Web represents the web server.

func (*Web) Run

func (wb *Web) Run(ctx context.Context) error

Run starts the web server.

Jump to

Keyboard shortcuts

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