Skip to content

Commit fb065f0

Browse files
committed
move dotweb/state to dotweb/core/state
1 parent 3919016 commit fb065f0

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

state.go renamed to core/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dotweb
1+
package core
22

33
import (
44
"sync/atomic"

state_test.go renamed to core/state_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dotweb
1+
package core
22

33
import (
44
"testing"

‎dotweb.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func freeMemory(ctx Context) error {
413413

414414
//显示服务器状态信息
415415
func showServerState(ctx Context) error {
416-
ctx.WriteString(jsonutil.GetJsonString(GlobalState))
416+
ctx.WriteString(jsonutil.GetJsonString(core.GlobalState))
417417
return nil
418418
}
419419

@@ -422,7 +422,7 @@ func showQuery(ctx Context) error {
422422
querykey := ctx.GetRouterName("key")
423423
switch querykey {
424424
case "state":
425-
ctx.WriteString(jsonutil.GetJsonString(GlobalState))
425+
ctx.WriteString(jsonutil.GetJsonString(core.GlobalState))
426426
case "":
427427
ctx.WriteString("please input key")
428428
default:

‎server.go‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dotweb
22

33
import (
44
"fmt"
5+
"github.com/devfeel/dotweb/core"
56
"github.com/devfeel/dotweb/framework/convert"
67
"github.com/devfeel/dotweb/framework/exception"
78
"github.com/devfeel/dotweb/framework/json"
@@ -252,7 +253,7 @@ func (server *HttpServer) wrapRouterHandle(handler HttpHandle, isHijack bool) Ro
252253
httpCtx.Response().SetHeader(HeaderContentEncoding, gzipScheme)
253254
}
254255
//增加状态计数
255-
GlobalState.AddRequestCount(1)
256+
core.GlobalState.AddRequestCount(1)
256257

257258
//session
258259
//if exists client-sessionid, use it
@@ -308,7 +309,7 @@ func (server *HttpServer) wrapRouterHandle(handler HttpHandle, isHijack bool) Ro
308309
}
309310

310311
//增加错误计数
311-
GlobalState.AddErrorCount(1)
312+
core.GlobalState.AddErrorCount(1)
312313
}
313314

314315
if server.ServerConfig.EnabledGzip {
@@ -368,7 +369,7 @@ func (server *HttpServer) wrapRouterHandle(handler HttpHandle, isHijack bool) Ro
368369
func (server *HttpServer) wrapFileHandle(fileHandler http.Handler) RouterHandle {
369370
return func(w http.ResponseWriter, r *http.Request, vnode *ValueNode) {
370371
//增加状态计数
371-
GlobalState.AddRequestCount(1)
372+
core.GlobalState.AddRequestCount(1)
372373
startTime := time.Now()
373374
r.URL.Path = vnode.ByName("filepath")
374375
fileHandler.ServeHTTP(w, r)
@@ -408,7 +409,7 @@ func (server *HttpServer) wrapWebSocketHandle(handler HttpHandle) websocket.Hand
408409
logger.Logger().Log(logString, LogTarget_HttpServer, LogLevel_Error)
409410

410411
//增加错误计数
411-
GlobalState.AddErrorCount(1)
412+
core.GlobalState.AddErrorCount(1)
412413
}
413414
timetaken := int64(time.Now().Sub(startTime) / time.Millisecond)
414415
//HttpServer Logging
@@ -425,7 +426,7 @@ func (server *HttpServer) wrapWebSocketHandle(handler HttpHandle) websocket.Hand
425426
handler(httpCtx)
426427

427428
//增加状态计数
428-
GlobalState.AddRequestCount(1)
429+
core.GlobalState.AddRequestCount(1)
429430
}
430431
}
431432

0 commit comments

Comments
 (0)