File server which specialized for SPA
Switch branches/tags
Nothing to show
Clone or download
Latest commit 5c4599f Jul 14, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/testserv fix example Jul 14, 2017
testdata better behaviors and tests Jul 14, 2017
LICENSE prototype Jul 13, 2017
README.md doc Jul 14, 2017
cut.go test and fix Jul 13, 2017
cut_test.go test and fix Jul 13, 2017
spafs.go better behaviors and tests Jul 14, 2017
spafs_test.go better behaviors and tests Jul 14, 2017

README.md

SPA Specialized File Server

spafs is a file server which specialized for SPA (single page application). This serves content of index.html in nearest ancestral directory for unavailable path.

How to use

Install and update:

go get -v -u github.com/koron/go-spafs

Example code:

package main

import (
    "http"
    spafs "github.com/koron/go-spafs"
)

func main() {
    fs := spafs.FileServer(http.Dir("./testdata"))
    err := http.ListenAndServe(":8080", fs)
    if err != nil {
        panic(err)
    }
}