github.com/vugu/vugu@v0.3.5/tinygo-dev/testpgm-srv.go (about) 1 // +build ignore 2 3 package main 4 5 import ( 6 "log" 7 "net/http" 8 "strings" 9 ) 10 11 const dir = "." 12 13 func main() { 14 fs := http.FileServer(http.Dir(dir)) 15 log.Print("Serving " + dir + " on http://localhost:8080") 16 http.ListenAndServe(":8080", http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { 17 resp.Header().Add("Cache-Control", "no-cache") 18 if strings.HasSuffix(req.URL.Path, ".wasm") { 19 resp.Header().Set("content-type", "application/wasm") 20 } 21 fs.ServeHTTP(resp, req) 22 })) 23 }