mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
Ensure content-type is explicitly set for WASM files
parent
f43537c729
commit
28eca6e028
@ -41,6 +41,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -51,7 +52,13 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
log.Printf("listening on %q...", *listen)
|
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)
|
||||||
|
})))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user