no message
parent
9614b34bd3
commit
f27ae731bb
|
@ -127,6 +127,7 @@ func GetArticleCount(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetArticle(c *gin.Context) {
|
func GetArticle(c *gin.Context) {
|
||||||
|
|
||||||
resp := RespBase{Msg: "FAIL", Status: 211}
|
resp := RespBase{Msg: "FAIL", Status: 211}
|
||||||
sid := c.Param("id")
|
sid := c.Param("id")
|
||||||
var id int
|
var id int
|
||||||
|
|
23
main.go
23
main.go
|
@ -11,6 +11,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"tcptemplate/logger"
|
||||||
"tcptemplate/network"
|
"tcptemplate/network"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"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)
|
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() {
|
func main() {
|
||||||
InitConfig()
|
InitConfig()
|
||||||
InitLogs()
|
InitLogs()
|
||||||
|
@ -104,10 +120,8 @@ func main() {
|
||||||
r.Use(CORSMiddleware) // Cross domain
|
r.Use(CORSMiddleware) // Cross domain
|
||||||
|
|
||||||
go func () {
|
go func () {
|
||||||
|
|
||||||
server := network.ServerFactory("0.0.0.0",config.ApiConfig().WsServerConf)
|
server := network.ServerFactory("0.0.0.0",config.ApiConfig().WsServerConf)
|
||||||
|
server.SetHandle(WsHandle{})
|
||||||
server.SetHandler(nil)
|
|
||||||
e := server.Run()
|
e := server.Run()
|
||||||
if nil != e {
|
if nil != e {
|
||||||
}
|
}
|
||||||
|
@ -217,8 +231,7 @@ func main() {
|
||||||
openapi.POST("/ddl2markdown", openapiController.DDL2Markdown) // sql ddl转markdown 文档
|
openapi.POST("/ddl2markdown", openapiController.DDL2Markdown) // sql ddl转markdown 文档
|
||||||
openapi.POST("/ui2css", openapiController.UI2CSS) // qt ui文件转css文档
|
openapi.POST("/ui2css", openapiController.UI2CSS) // qt ui文件转css文档
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
e := r.Run(":" + strconv.Itoa(config.GetPort()))
|
e := r.Run(":" + strconv.Itoa(config.GetPort()))
|
||||||
if nil != e {
|
if nil != e {
|
||||||
log.Print(e.Error())
|
log.Print(e.Error())
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* @Author: your name
|
* @Author: your name
|
||||||
* @Date: 2021-08-02 00:02:17
|
* @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
|
* @LastEditors: Please set LastEditors
|
||||||
* @Description: In User Settings Edit
|
* @Description: In User Settings Edit
|
||||||
* @FilePath: \background\test\goroutine_test.go
|
* @FilePath: \background\test\goroutine_test.go
|
||||||
|
@ -68,23 +68,30 @@ func TestChanel(t *testing.T){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TestInherit struct{
|
||||||
|
context.Context
|
||||||
|
x int32
|
||||||
|
|
||||||
|
}
|
||||||
func TestTimeoutContext(t * testing.T){
|
func TestTimeoutContext(t * testing.T){
|
||||||
ctx,_ := context.WithTimeout(context.Background(), time.Second)
|
ctx,_ := context.WithTimeout(context.Background(), time.Second * 1)
|
||||||
|
aa := TestInherit{ctx,1}
|
||||||
|
|
||||||
go func () {
|
go func (aa *TestInherit) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-aa.Done():
|
||||||
t.Logf("exit")
|
t.Logf("exit")
|
||||||
return
|
return
|
||||||
case <- time.After(2 * time.Second) :
|
case <- time.After(5 * time.Second) :
|
||||||
t.Logf("time out ")
|
t.Logf("time out ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}(&aa)
|
||||||
|
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContext(t *testing.T){
|
func TestContext(t *testing.T){
|
||||||
ctx,cancel := context.WithCancel(context.Background())
|
ctx,cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue