This commit is contained in:
Nicolas Lepage 2020-05-29 00:40:28 +02:00
parent 0a1eee9812
commit 5f09cb3c8a
No known key found for this signature in database
GPG Key ID: B0879E35E66D8F6F
3 changed files with 11 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"time"
wasmhttp "github.com/nlepage/go-wasm-http-server"
)
@ -11,9 +12,10 @@ import (
var no = 1
func main() {
fmt.Println("Starting...")
http.HandleFunc("/hello", func(res http.ResponseWriter, req *http.Request) {
h, m, s := time.Now().Clock()
fmt.Printf("hello at %02d:%02d:%02d\n", h, m, s)
params := make(map[string]string)
if err := json.NewDecoder(req.Body).Decode(&params); err != nil {
panic(err)
@ -29,7 +31,12 @@ func main() {
wasmhttp.Serve(nil)
fmt.Println("Started")
go func() {
for range time.Tick(time.Second) {
h, m, s := time.Now().Clock()
fmt.Printf("tick at %02d:%02d:%02d\n", h, m, s)
}
}()
select {}
}

Binary file not shown.