go.static: github.com/daaku/go.static Index | Files

package static

import "github.com/daaku/go.static"

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

Package Files

static.go

func NewContext Uses

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

func URL Uses

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

type Box Uses

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 Uses

func FileSystemBox(fs http.FileSystem) Box

FileSystemBox returns a Box from a http.FileSystem.

type Favicon Uses

type Favicon struct {
    HREF string
}

Favicon provides a h.Link for a favicon.

func (*Favicon) HTML Uses

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

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

type Handler Uses

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 Uses

func FromContext(ctx context.Context) *Handler

func (*Handler) ServeHTTP Uses

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

ServeHTTP handles requests for hashed URLs.

func (*Handler) URL Uses

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 Uses

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 Uses

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

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

type Input Uses

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 Uses

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

HTML renders the content.

type LinkStyle Uses

type LinkStyle struct {
    HREF []string
}

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

func (*LinkStyle) HTML Uses

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

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

type Script Uses

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 Uses

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

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

Package static imports 18 packages (graph) and is imported by 7 packages. Updated 2016-07-22. Refresh now. Tools for package owners.