static

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content interface {
	Get(path string) (*FileInfo, io.ReadCloser)
	Exists(path string) bool
}

Content controls what is rendered inside ServeFs.

type FileInfo

type FileInfo struct {
	Hash string

	// Is this Hash purely from the file's contents. If false, and Hash is set, is from the filename.
	ContentHash bool

	// ContentType if known.
	ContentType string

	// Additional headers to include, e.g, for CSP
	Header http.Header
}

FileInfo is returned from Content.

type ServeFs

type ServeFs struct {
	Content Content

	// AddPrefix is added to all paths before being checked inside Content.
	AddPrefix string

	// AllowFrame controls the X-Frame-Options header.
	AllowFrame bool

	// HtmlNotFoundPath is loaded from Content if we think this is a missing page (with a trailing slash). It does not have AddPrefix applied to it.
	HtmlNotFoundPath string

	// UpdateHeader may be provided to update the headers of returned responses. Useful for CSP.
	UpdateHeader func(http.Header, ServeInfo)
}

ServeFs implements http.Handler.

func (*ServeFs) ServeHTTP

func (c *ServeFs) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServeInfo

type ServeInfo struct {
	FileInfo
	Is404        bool
	IsHtml       bool
	IsHead       bool
	IfNoneMatch  bool
	CacheForever bool
}

ServeInfo is passed to UpdateHeader to control header generation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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