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

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

func URL

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

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.

Package static imports 18 packages (graph) and is imported by 7 packages. Updated 2015-10-01. Refresh now. Tools for package owners.