Skip to content

Commit

Permalink
fix exit
Browse files Browse the repository at this point in the history
  • Loading branch information
isinged committed Mar 6, 2021
1 parent 8895923 commit adf9716
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion srv.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ func (s *Srv) NewContext(server ServerAdapter, sid string, req *Request) *Contex
if ok {
handlers = make([]HandlerFunc, 0, len(s.middleware)+len(routeHandlers)+len(s.internalMiddleware))
handlers = append(handlers, s.middleware...)
handlers = append(handlers, s.internalMiddleware...)
handlers = append(handlers, routeHandlers...)
ctx.OK() // 匹配到了路由,但是 handler 没有设置响应
} else {
handlers = make([]HandlerFunc, 0, len(s.middleware)+1)
handlers = append(handlers, s.middleware...)
}
handlers = append(handlers, s.internalMiddleware...)
ctx.handlers = handlers
ctx.handlerIndex = -1
return ctx
Expand Down
10 changes: 5 additions & 5 deletions srv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ func TestSrv_Exit(t *testing.T) {
c.Set("td", c.Get("td").(string)+"d")
})

srv.Run()
go srv.Run()
time.Sleep(50 * time.Millisecond)

t.Assert(srv.GetState("test.sid", "ta"), "acb")
t.Assert(srv.GetState("test.sid", "tb"), "ac")
t.Assert(srv.GetState("test.sid", "tc"), "acdb")
t.Assert(srv.GetState("test.sid", "td"), "ac")
t.Assert(srv.GetState("", "ta"), "acb")
t.Assert(srv.GetState("", "tb"), "acb")
t.Assert(srv.GetState("", "tc"), "acdb")
t.Assert(srv.GetState("", "td"), "acb")
})

}

0 comments on commit adf9716

Please sign in to comment.