statik

package
v0.0.0-...-820a931 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 22 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPath = errors.New("invalid file path")
)

Functions

func AssetPath

func AssetPath(domain, name string, context ...string) string

AssetPath return the fullpath with unique identifier for a given asset file.

func ExtractAssetID

func ExtractAssetID(file string) (string, string)

ExtractAssetID checks if a long hexadecimal string is contained in given file path and returns the original file name and ID (if any). For instance <foo.badbeedbadbeef.min.js> = <foo.min.js, badbeefbadbeef>

func GetLanguageFromHeader

func GetLanguageFromHeader(header http.Header) (lang string)

GetLanguageFromHeader return the language tag given the Accept-Language header.

Types

type AssetRenderer

type AssetRenderer interface {
	echo.Renderer
	http.Handler
}

AssetRenderer is an interface for both a template renderer and an asset HTTP handler.

func NewDirRenderer

func NewDirRenderer(assetsPath string) (AssetRenderer, error)

NewDirRenderer returns a renderer with assets opened from a specified local directory.

func NewRenderer

func NewRenderer() (AssetRenderer, error)

NewRenderer return a renderer with assets loaded form their packed representation into the binary.

type Handler

type Handler struct{}

Handler implements http.handler for a subpart of the available assets on a specified prefix.

func NewHandler

func NewHandler() Handler

NewHandler returns a new handler

func (*Handler) ServeFile

func (h *Handler) ServeFile(w http.ResponseWriter, r *http.Request, f *modelAsset.Asset, checkETag bool)

ServeFile can be used to respond with an asset file to an HTTP request

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

Jump to

Keyboard shortcuts

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