diff --git a/docs/hello-state/api.go b/docs/hello-state/api.go new file mode 100644 index 0000000..c1e201d --- /dev/null +++ b/docs/hello-state/api.go @@ -0,0 +1,32 @@ +package main + +import ( + "encoding/json" + "fmt" + "net/http" + + wasmhttp "github.com/nlepage/go-wasm-http-server" +) + +func main() { + var no = 1 + + http.HandleFunc("/hello", func(res http.ResponseWriter, req *http.Request) { + params := make(map[string]string) + if err := json.NewDecoder(req.Body).Decode(¶ms); err != nil { + panic(err) + } + + if err := json.NewEncoder(res).Encode(map[string]string{ + "message": fmt.Sprintf("Hello %s! (request n°%d)", params["name"], no), + }); err != nil { + panic(err) + } + + no++ + }) + + wasmhttp.Serve(nil) + + select {} +} diff --git a/docs/hello-state/api.wasm b/docs/hello-state/api.wasm new file mode 100755 index 0000000..edced6d Binary files /dev/null and b/docs/hello-state/api.wasm differ diff --git a/docs/hello-state/index.html b/docs/hello-state/index.html new file mode 100644 index 0000000..62fa87f --- /dev/null +++ b/docs/hello-state/index.html @@ -0,0 +1,25 @@ + + +
+