From c01dc6b5af93e0357835a4ecaa791556ea5a3c9d Mon Sep 17 00:00:00 2001 From: hoteas Date: Wed, 23 Aug 2017 02:33:51 +0000 Subject: [PATCH] demo --- .idea/workspace.xml | 208 +++++++++++++++++++++++--------------------- config/config.json | 2 +- db.go | 4 +- example/main.go | 8 +- func.go | 7 +- 5 files changed, 121 insertions(+), 108 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 81f65c1..4ed696e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,7 +6,10 @@ + + + \ No newline at end of file diff --git a/config/config.json b/config/config.json index efbdac0..3d4ee02 100644 --- a/config/config.json +++ b/config/config.json @@ -12,7 +12,7 @@ ], "error": {}, "logLevel": 0, - "port": "8080", + "port": "80", "sessionName": "HOTIME", "tpt": "tpt" } \ No newline at end of file diff --git a/db.go b/db.go index d95072d..80f65cc 100644 --- a/db.go +++ b/db.go @@ -43,12 +43,12 @@ func (this *HoTimeDB) Action(action func() bool) bool { if !result { this.Tx.Rollback() this.Tx = nil - return true + return result } this.Tx.Commit() this.Tx = nil - return true + return result } func (this *HoTimeDB) InitDb(err ...*Error) Error { diff --git a/example/main.go b/example/main.go index 1808146..9344ca6 100644 --- a/example/main.go +++ b/example/main.go @@ -50,11 +50,13 @@ func main() { "index": hotime.Ctr{ "test": func(this *hotime.Context) { fmt.Println(this.Db.GetTag()) - this.Db.Action(func() bool { + x:=this.Db.Action(func() bool { - return true + this.Db.Insert("user",hotime.Map{"unickname":"dasdas"}) + + return false }) - this.Display(5, "chenggong") + this.Display(5, x) }, "websocket": func(this *hotime.Context) { hdler := websocket.Handler(func(ws *websocket.Conn) { diff --git a/func.go b/func.go index 23b8b70..bd5884d 100644 --- a/func.go +++ b/func.go @@ -304,8 +304,11 @@ func run(a *Application) { if !IsRun { http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { - port := Substr(req.Host, IndexLastStr(req.Host, ":")+1, len(req.Host)) - //fmt.Println(port) + port:="80" + if IndexLastStr(req.Host, ":")!=-1{ + port = Substr(req.Host, IndexLastStr(req.Host, ":")+1, len(req.Host)) + } + if application[port] != nil { application[port].handler(w, req) }