Home

Awesome

StaticBin wercker status GoDoc

Martini middleware/handler for serving static files from binary data

Usage

package main

import (
	"github.com/go-martini/martini"
	"github.com/martini-contrib/staticbin"
)

func main() {
	m := martini.Classic()

	// Serves the "static" directory's files from binary data.
	// You have to pass the "Asset" function generated by
	// go-bindata (https://github.com/jteeuwen/go-bindata).
	m.Use(staticbin.Static("static", Asset))

	m.Get("/", func() string {
		return "Hello world!"
	})

	m.Run()
}

Get a classic Martini which serves the "public" directory's files from binary data by default

A classic Martini generated by martini.Classic serves the "public" directory's files by default. You can get one which serves the "public" directory's files from binary data by default by using staticbin.Classic.

package main

import "github.com/martini-contrib/staticbin"

func main() {
	// staticbin.Classic(Asset) instance automatically serves the "public" directory's files
	// from binary data by default.
	m := staticbin.Classic(Asset)

	// You can serve from more directories by adding more staticbin.Static handlers.
	//   m.Use(staticbin.Static("static", Asset))

	m.Get("/", func() string {
		return "Hello world!"
	})

	m.Run()
}

Sample package using StaticBin

Doc