This commit is contained in:
Nicolas Lepage 2019-12-02 17:22:48 +01:00
parent 3d97d94c35
commit 22f54438b8
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F
2 changed files with 4 additions and 1 deletions

View File

@ -8,6 +8,8 @@ import (
wasmhttp "github.com/nlepage/go-wasm-http-server" wasmhttp "github.com/nlepage/go-wasm-http-server"
) )
var no = 1
func main() { func main() {
http.HandleFunc("/hello", func(res http.ResponseWriter, req *http.Request) { http.HandleFunc("/hello", func(res http.ResponseWriter, req *http.Request) {
params := make(map[string]string) params := make(map[string]string)
@ -16,10 +18,11 @@ func main() {
} }
if err := json.NewEncoder(res).Encode(map[string]string{ if err := json.NewEncoder(res).Encode(map[string]string{
"message": fmt.Sprintf("Hello %s!", params["name"]), "message": fmt.Sprintf("Hello %s! (%d)", params["name"], no),
}); err != nil { }); err != nil {
panic(err) panic(err)
} }
no++
}) })
wasmhttp.Serve(nil) wasmhttp.Serve(nil)

Binary file not shown.