mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
Ensure content-type is explicitly set for WASM files
parent
f43537c729
commit
28eca6e028
@ -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)
|
||||
})))
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user