mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2026-01-12 01:59:14 +00:00
Adds an example that demonstrates TinyGo compatibility, as well as using a server-side HTTP handler as a fallback.
20 lines
405 B
Go
20 lines
405 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"runtime"
|
|
)
|
|
|
|
func goRuntimeHandler(res http.ResponseWriter, req *http.Request) {
|
|
res.Header().Add("Content-Type", "application/json")
|
|
if err := json.NewEncoder(res).Encode(map[string]string{
|
|
"os": runtime.GOOS,
|
|
"arch": runtime.GOARCH,
|
|
"compiler": runtime.Compiler,
|
|
"version": runtime.Version(),
|
|
}); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|