Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts Options) gear.Middleware
New creates a static middleware to serves static content from the provided root directory.
package main import ( "github.com/teambition/gear" "github.com/teambition/gear/middleware/favicon" "github.com/teambition/gear/middleware/static" ) func main() { app := gear.New() app.Use(favicon.New("./testdata/favicon.ico")) app.Use(static.New(static.Options{ Root: "./testdata", Prefix: "/", StripPrefix: false, })) app.Use(func(ctx *gear.Context) error { return ctx.HTML(200, "<h1>Hello, Gear!</h1>") }) app.Error(app.Listen(":3000")) }
Types ¶
type Options ¶
type Options struct { Root string // The directory you wish to serve Prefix string // The url prefix you wish to serve as static request, default to `'/'`. StripPrefix bool // Strip the prefix from URL path, default to `false`. Files map[string][]byte // Optional, a map of File objects to serve. }
Options is static middleware options
Click to show internal directories.
Click to hide internal directories.