mirror of
https://github.com/nlepage/go-wasm-http-server.git
synced 2025-03-10 17:29:10 +00:00
⚗️
This commit is contained in:
parent
0a1eee9812
commit
5f09cb3c8a
13
docs/api.go
13
docs/api.go
@ -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(¶ms); 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 {}
|
||||
}
|
||||
|
BIN
docs/api.wasm
BIN
docs/api.wasm
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user