static

package module
v0.0.0-...-448c30a Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2016 License: BSD-3-Clause Imports: 18 Imported by: 0

README

go.static Build Status

Package static provides go.h compatible hashed static assets: https://godoc.org/github.com/daaku/go.static

Documentation

Overview

Package static provides go.h compatible hashed static assets. This allows for providing long lived cache headers for resources which change URLs as their content changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, h *Handler) context.Context

func URL

func URL(ctx context.Context, names ...string) (string, error)

Types

type Box

type Box interface {
	Bytes(name string) ([]byte, error)
}

Box is where the files are loaded from. You'll probably want to use https://github.com/GeertJohan/go.rice or FileSystemBox.

func FileSystemBox

func FileSystemBox(fs http.FileSystem) Box

FileSystemBox returns a Box from a http.FileSystem.

type Favicon

type Favicon struct {
	HREF string
}

Favicon provides a h.Link for a favicon.

func (*Favicon) HTML

func (l *Favicon) HTML(ctx context.Context) (h.HTML, error)

HTML returns the <script> tag with the appropriate attributes.

type Handler

type Handler struct {
	Path string // Path at which Handler is configured.
	Box  Box    // Box of files to serve.
	// contains filtered or unexported fields
}

Handler serves and provides URLs for static resources.

func FromContext

func FromContext(ctx context.Context) *Handler

func (*Handler) ServeHTTP

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

ServeHTTP handles requests for hashed URLs.

func (*Handler) URL

func (h *Handler) URL(names ...string) (string, error)

URL returns a hashed URL for all the given component names. It uses the extension of the first file as the extension for the generated URL.

type Img

type Img struct {
	ID    string
	Class string
	Style string
	Src   string
	Alt   string
}

Img provides a h.Img where the src is served using the specified Handler.

func (*Img) HTML

func (i *Img) HTML(ctx context.Context) (h.HTML, error)

HTML returns the <img> tag with the appropriate attributes.

type Input

type Input struct {
	ID          string
	Class       string
	Name        string
	Style       string
	Type        string
	Value       string
	Src         string
	Placeholder string
	Checked     bool
	Multiple    bool
	Data        map[string]interface{}
	Inner       h.HTML
}

Input renders a HTML <input> tag with the Src URL transformed.

func (*Input) HTML

func (i *Input) HTML(ctx context.Context) (h.HTML, error)

HTML renders the content.

type LinkStyle

type LinkStyle struct {
	HREF []string
}

LinkStyle provides a h.LinkStyle where the HREFs are combined and served using the specified Handler.

func (*LinkStyle) HTML

func (l *LinkStyle) HTML(ctx context.Context) (h.HTML, error)

HTML returns the <link> tag with the appropriate attributes.

type Script

type Script struct {
	Src   []string
	Async bool
}

Script provides a h.Script where the Srcs are combined and served using the specified Handler.

func (*Script) HTML

func (l *Script) HTML(ctx context.Context) (h.HTML, error)

HTML returns the <script> tag with the appropriate attributes.

Jump to

Keyboard shortcuts

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