mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2025-03-11 01:29:11 +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)
|
|
}
|
|
}
|