diff --git a/WebAssembly.md b/WebAssembly.md index 78131c4b..bfa1e3bc 100644 --- a/WebAssembly.md +++ b/WebAssembly.md @@ -41,6 +41,7 @@ import ( "flag" "log" "net/http" + "strings" ) var ( @@ -51,7 +52,13 @@ var ( func main() { flag.Parse() log.Printf("listening on %q...", *listen) - log.Fatal(http.ListenAndServe(*listen, http.FileServer(http.Dir(*dir)))) + log.Fatal(http.ListenAndServe(*listen, http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { + if strings.HasSuffix(req.URL.Path, ".wasm") { + resp.Header().Set("content-type", "application/wasm") + } + + http.FileServer(http.Dir(*dir)).ServeHTTP(resp, req) + }))) } ```