static

package module
v0.0.0-...-dc70328 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2017 License: MIT Imports: 10 Imported by: 0

README

static

Build Status GoDoc

A static assets handler for the gin framework that can serve files from assets generated by go-bindata.

Check the demo to see an example fileserver.

Documentation

Index

Constants

View Source
const (
	// DefaultMaxAge is 60 days.
	DefaultMaxAge = 86400
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentFunc

type ContentFunc func(string) ([]byte, error)

ContentFunc is an alias for the Asset method of the generated bindata.go file.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is the base struct used to serve the bindata.

func NewGzipHandler

func NewGzipHandler(contentFn ContentFunc, namesFn NamesFunc, level int) (*Handler, error)

NewGzipHandler return a handler that compress the assets. The level parameter is the compression level used by gzip, see: https://golang.org/pkg/compress/gzip/#pkg-constants

func NewHandler

func NewHandler(contentFn ContentFunc, namesFn NamesFunc) *Handler

NewHandler create a new Handler. contentFn is the Asset method and namesFn is the AssetNames method from the generated bindata.go.

func (*Handler) AddIndexes

func (h *Handler) AddIndexes(names ...string)

AddIndexes adds possible indexes. For example if there are one or more directories that contains an index.html file that you want to serve when the directory name is requested then add "index.html".

func (*Handler) Register

func (h *Handler) Register(r *gin.RouterGroup)

Register adds the static handlers to the gin.RouterGroup.

func (*Handler) SetMaxAge

func (h *Handler) SetMaxAge(ma uint)

SetMaxAge sets the max-age header (if set to 0 then caching is disabled).

type NamesFunc

type NamesFunc func() []string

NamesFunc is an alias for the AssetNames method of the generated bindata.go file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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