mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
添加底层函数
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package GateService
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/duanhf2012/origin/event"
|
||||
"github.com/duanhf2012/origin/network"
|
||||
@@ -25,7 +26,8 @@ func (slf *GateService) OnInit() error{
|
||||
slf.httpRouter = sysservice.NewHttpHttpRouter(slf)
|
||||
httpervice.SetHttpRouter(slf.httpRouter)
|
||||
|
||||
slf.httpRouter.RegRouter(sysservice.METHOD_GET,"/get/query",slf.HttpTest)
|
||||
slf.httpRouter.GET("/get/query", slf.HttpTest)
|
||||
slf.httpRouter.POST("/post/query", slf.HttpTestPost)
|
||||
slf.httpRouter.SetServeFile(sysservice.METHOD_GET,"/img/head/","d:/img")
|
||||
return nil
|
||||
}
|
||||
@@ -38,6 +40,26 @@ func (slf *GateService) HttpTest(session *sysservice.HttpSession) {
|
||||
fmt.Print(string(session.GetBody()),"\n",v,"\n",v2)
|
||||
}
|
||||
|
||||
func (slf *GateService) HttpTestPost(session *sysservice.HttpSession) {
|
||||
session.SetHeader("a","b")
|
||||
v,_:=session.Query("a")
|
||||
v2,_:=session.Query("b")
|
||||
|
||||
byteBody := session.GetBody()
|
||||
fmt.Print(string(session.GetBody()),"\n",v,"\n",v2)
|
||||
|
||||
testa := struct {
|
||||
AA int `json:"aa"`
|
||||
BB string `json:"bb"`
|
||||
}{}
|
||||
json.Unmarshal(byteBody, &testa)
|
||||
fmt.Println(testa)
|
||||
|
||||
testa.AA = 100
|
||||
testa.BB = "this is a test"
|
||||
session.WriteJson("asdasda")
|
||||
}
|
||||
|
||||
func (slf *GateService) OnEventHandler(ev *event.Event) error{
|
||||
if ev.Type == event.Sys_Event_Tcp_RecvPack {
|
||||
pPack := ev.Data.(*sysservice.TcpPack)
|
||||
|
||||
Reference in New Issue
Block a user