2 Commits

Author SHA1 Message Date
eson
f1729f129a feat(logger): delete Logger() 2020-11-26 17:36:57 +08:00
eson
f61302d25f style(ginmode): set gin mode release 2020-11-26 17:26:19 +08:00
2 changed files with 26 additions and 1 deletions

View File

@@ -168,7 +168,10 @@ func (cli *Client) Connect() {
}
cli.port = fmt.Sprintf("%d", listener.Addr().(*net.TCPAddr).Port)
router := gin.Default()
router := gin.New()
router.Use(gin.Recovery())
gin.SetMode(gin.ReleaseMode)
router.POST("/:label", func(c *gin.Context) {
label := c.Param("label")
if f, ok := cli.register.Load(label); ok {

View File

@@ -5,8 +5,30 @@ import (
"log"
"net/http"
"testing"
"time"
)
func TestSelectChan(t *testing.T) {
var a chan string = make(chan string)
var b chan string = make(chan string)
go func() {
time.Sleep(time.Second * 2)
a <- "1"
time.Sleep(time.Second * 2)
b <- "2"
}()
select {
case s := <-a:
log.Println("a", s)
case s := <-b:
log.Println("b", s)
case <-time.After(time.Second * 5):
log.Println("timeout 5s")
}
}
func TestPort(t *testing.T) {
cli := New("http://localhost:7123")