Skip to content

Latest commit

 

History

History

indexfs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

indexfs

Go lang index http.FileSystem

Installation

$ go get github.com/gnue/httpfs/indexfs

Usage

import "github.com/gnue/httpfs/indexfs"

Examples

IndexFS

package main

import (
	"github.com/gnue/httpfs/indexfs"
	"net/http"
)

func main() {
	fs := indexfs.New(http.Dir("sites"), func(fs http.FileSystem, dir string) (http.File, error) {
		return indexfs.OpenIndex(fs, dir, "index.html", "index.htm")
	})

	http.Handle("/", http.FileServer(fs))
	http.ListenAndServe(":8080", nil)
}

Simple index webserver

indexes := indexfs.Indexes{"index.html", "index.htm"}
fs := indexfs.New(http.Dir("test"), indexes.DirIndex)
indexes := indexfs.Indexes{"index.html", "index.htm"}
fs := indexfs.New(http.Dir("test"), indexes.AutoIndex)

Author

gnue

License

MIT