优化日志及config

This commit is contained in:
hoteas
2022-07-11 19:13:20 +08:00
parent 15b73b3ce7
commit e37b7b586b
6 changed files with 119 additions and 81 deletions
+28 -7
View File
@@ -4,6 +4,7 @@ import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"fmt"
"golang.org/x/net/websocket"
)
func main() {
@@ -13,15 +14,35 @@ func main() {
"user": Ctr{
"test": func(that *Context) {
fmt.Println("dasdasd")
id := that.Db.Insert("user", Map{"name": "test"})
ok := that.Db.Update("user", Map{"name": "test1"}, Map{"name": "test"})
//id := that.Db.Insert("user", Map{"name": "test"})
//ok := that.Db.Update("user", Map{"name": "test1"}, Map{"name": "test"})
ps := that.Db.Select("user", "*")
p := that.Db.Get("user", "*")
row := that.Db.Delete("user", Map{"id": id})
that.Display(0, Slice{id, ok, ps, p, row})
//row := that.Db.Delete("user", Map{"id": id})
//that.Display(0, Slice{id, ok, ps, p, row})
that.Display(0, Slice{ps, p})
},
},
},
})
"websocket": func(that *Context) {
hdler := websocket.Handler(func(ws *websocket.Conn) {
for true {
msg := make([]byte, 5120)
n, err := ws.Read(msg)
if err != nil {
return
}
fmt.Printf("Receive: %s\n", msg[:n])
send_msg := "[" + string(msg[:n]) + "]"
m, err := ws.Write([]byte(send_msg))
if err != nil {
return
}
fmt.Printf("Send: %s\n", msg[:m])
}
})
hdler.ServeHTTP(that.Resp, that.Req)
},
}}})
}