no message
parent
9614b34bd3
commit
f27ae731bb
|
@ -127,6 +127,7 @@ func GetArticleCount(c *gin.Context) {
|
|||
}
|
||||
|
||||
func GetArticle(c *gin.Context) {
|
||||
|
||||
resp := RespBase{Msg: "FAIL", Status: 211}
|
||||
sid := c.Param("id")
|
||||
var id int
|
||||
|
|
21
main.go
21
main.go
|
@ -11,6 +11,7 @@ import (
|
|||
"log"
|
||||
"strconv"
|
||||
|
||||
"tcptemplate/logger"
|
||||
"tcptemplate/network"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -92,6 +93,21 @@ func InitLogs() {
|
|||
logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile)
|
||||
}
|
||||
|
||||
type WsHandle struct{
|
||||
|
||||
}
|
||||
func (this WsHandle) OnDisConected(*network.ConnectionContext) {
|
||||
|
||||
}
|
||||
func (this WsHandle) OnConected(c *network.ConnectionContext) {
|
||||
log.Print(c.IpAdress,c.Cnntime)
|
||||
}
|
||||
func (this WsHandle) OnDataRecv(p *network.ConnectionContext, dat []byte) {
|
||||
log.Print(p.IpAdress)
|
||||
logger.LogRealeaseInfo(string(dat))
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
InitConfig()
|
||||
InitLogs()
|
||||
|
@ -104,10 +120,8 @@ func main() {
|
|||
r.Use(CORSMiddleware) // Cross domain
|
||||
|
||||
go func () {
|
||||
|
||||
server := network.ServerFactory("0.0.0.0",config.ApiConfig().WsServerConf)
|
||||
|
||||
server.SetHandler(nil)
|
||||
server.SetHandle(WsHandle{})
|
||||
e := server.Run()
|
||||
if nil != e {
|
||||
}
|
||||
|
@ -218,7 +232,6 @@ func main() {
|
|||
openapi.POST("/ui2css", openapiController.UI2CSS) // qt ui文件转css文档
|
||||
}
|
||||
|
||||
|
||||
e := r.Run(":" + strconv.Itoa(config.GetPort()))
|
||||
if nil != e {
|
||||
log.Print(e.Error())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* @Author: your name
|
||||
* @Date: 2021-08-02 00:02:17
|
||||
* @LastEditTime: 2021-08-15 23:15:46
|
||||
* @LastEditTime: 2021-08-24 23:18:40
|
||||
* @LastEditors: Please set LastEditors
|
||||
* @Description: In User Settings Edit
|
||||
* @FilePath: \background\test\goroutine_test.go
|
||||
|
@ -68,23 +68,30 @@ func TestChanel(t *testing.T){
|
|||
|
||||
}
|
||||
|
||||
func TestTimeoutContext(t * testing.T){
|
||||
ctx,_ := context.WithTimeout(context.Background(), time.Second)
|
||||
type TestInherit struct{
|
||||
context.Context
|
||||
x int32
|
||||
|
||||
go func () {
|
||||
}
|
||||
func TestTimeoutContext(t * testing.T){
|
||||
ctx,_ := context.WithTimeout(context.Background(), time.Second * 1)
|
||||
aa := TestInherit{ctx,1}
|
||||
|
||||
go func (aa *TestInherit) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
case <-aa.Done():
|
||||
t.Logf("exit")
|
||||
return
|
||||
case <- time.After(2 * time.Second) :
|
||||
case <- time.After(5 * time.Second) :
|
||||
t.Logf("time out ")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}(&aa)
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
|
||||
func TestContext(t *testing.T){
|
||||
ctx,cancel := context.WithCancel(context.Background())
|
||||
|
||||
|
|
Loading…
Reference in New Issue