Created
October 16, 2014 16:53
-
-
Save spheromak/bb8c591689e8c5f8aaac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
"github.com/elazarl/go-bindata-assetfs" | |
) | |
// staticHanlder handles all requessts by returning the index.html | |
func staticHandler(w http.ResponseWriter, r *http.Request) { | |
data, err := Asset("data/index.html") | |
if err != nil { | |
log.Fatal("error while reading embedded data for 'index.html'") | |
} | |
w.Write(data) | |
} | |
func main() { | |
// register the packed data in pics to /pics | |
http.Handle("/pics/", http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "data"})) | |
// everthing else served by staticHandler (index.html) | |
http.HandleFunc("/", staticHandler) | |
// serve | |
http.ListenAndServe(":9089", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment