statio

package module
v0.0.0-...-71f3ca7 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: MIT Imports: 5 Imported by: 0

README

statio

serves static files and http file system

package main

import (
	"github.com/macross-contrib/statio"
	"macross"
)

func main() {
	m := macross.New()

	// if Allow DirectoryIndex
	//m.Use(statio.Serve("/", statio.LocalFile("/tmp", true)))
	// set prefix
	//m.Use(statio.Serve("/static", statio.LocalFile("/tmp", true)))

	m.Use(statio.Serve("/", statio.LocalFile("/tmp", false)))
	m.Get("/ping", func(self *macross.Context) error {
		return self.String("pong")
	})
	// Listen and Server in 0.0.0.0:8080
	m.Listen(":8080")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(root string, listDirectory bool) http.FileSystem

Dir returns a http.Filesystem that can be used by http.FileServer(). It is used interally in router.Static(). if listDirectory == true, then it works the same as http.Dir() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.

func LocalFile

func LocalFile(root string, indexes bool) *localFileSystem

func Serve

func Serve(urlPrefix string, fs ServeFileSystem) macross.Handler

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

func ServeRoot

func ServeRoot(urlPrefix, root string) macross.Handler

Types

type ServeFileSystem

type ServeFileSystem interface {
	http.FileSystem
	Exists(prefix string, path string) bool
}

Directories

Path Synopsis
example
bindata command
simple command

Jump to

Keyboard shortcuts

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