修改http返回

This commit is contained in:
duanhf2012
2020-04-11 10:03:03 +08:00
parent c7c1558cc3
commit ff8ec204f6
2 changed files with 21 additions and 8 deletions

View File

@@ -9,6 +9,8 @@ import (
"github.com/duanhf2012/origin/node"
"github.com/duanhf2012/origin/service"
"github.com/duanhf2012/origin/sysservice"
"github.com/duanhf2012/origin/util/timer"
"net/http"
)
type GateService struct {
@@ -29,9 +31,17 @@ func (slf *GateService) OnInit() error{
slf.httpRouter.GET("/get/query", slf.HttpTest)
slf.httpRouter.POST("/post/query", slf.HttpTestPost)
slf.httpRouter.SetServeFile(sysservice.METHOD_GET,"/img/head/","d:/img")
pCronExpr,_ := timer.NewCronExpr("0 * * * * *")
slf.CronFunc(pCronExpr,slf.Test)
return nil
}
func (slf *GateService) Test(){
fmt.Print("xxxxx\n")
}
func (slf *GateService) HttpTest(session *sysservice.HttpSession) {
session.SetHeader("a","b")
session.Write([]byte("this is a test"))
@@ -57,10 +67,11 @@ func (slf *GateService) HttpTestPost(session *sysservice.HttpSession) {
testa.AA = 100
testa.BB = "this is a test"
session.WriteJson("asdasda")
session.WriteJsonDone(http.StatusOK,"asdasda")
}
func (slf *GateService) OnEventHandler(ev *event.Event) error{
if ev.Type == event.Sys_Event_Tcp_RecvPack {
pPack := ev.Data.(*sysservice.TcpPack)
slf.processor.Route(ev.Data,pPack.ClientId)