staticbin

package module
v0.0.0-...-588762e Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2015 License: MIT Imports: 7 Imported by: 4

README

StaticBin wercker status GoDoc

Gin middleware/handler for serving static files from binary data.

Usage

package main

import (
  "github.com/gin-gonic/gin"
  "github.com/olebedev/staticbin"
)

func main() {
  r := gin.New() // without any middlewares

  // 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).
  r.Use(staticbin.Static(Asset, staticbin.Options{
    // Dir prefix will be trimmed. It needs to separate namespace.
    Dir: "/static",
  }))

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

  r.Run(":8080")
}

Documentation

Overview

Based on https://github.com/martini-contrib/staticbin

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Static

func Static(asset func(string) ([]byte, error), options ...Options) gin.HandlerFunc

Static returns a middleware handler that serves static files in the given directory.

Types

type Options

type Options struct {
	// SkipLogging will disable [Static] log messages when a static file is served.
	SkipLogging bool
	// IndexFile defines which file to serve as index if it exists.
	IndexFile string
	// Path prefix
	Dir string
}

Jump to

Keyboard shortcuts

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