1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-10 13:35:59 +00:00

Add virtual listen same as NoListen- some changes in order the server_test no need any system modification

This commit is contained in:
Makis Maropoulos
2016-07-05 14:29:32 +02:00
parent 93dc7c7e48
commit afa5b57dc7
5 changed files with 59 additions and 39 deletions

View File

@@ -179,6 +179,7 @@ func (s *Framework) openServer() (err error) {
// set the server's handler now, in order to give the chance to the plugins to add their own middlewares and routes to this station
s.HTTPServer.SetHandler(s.mux)
if err = s.HTTPServer.Open(); err == nil {
// print the banner
if !s.Config.DisableBanner {
s.Logger.PrintBanner(banner,
@@ -186,10 +187,16 @@ func (s *Framework) openServer() (err error) {
s.HTTPServer.Host()))
}
s.Plugins.DoPostListen(s)
s.Available <- true
ch := make(chan os.Signal)
<-ch
s.Close()
go func() {
s.Available <- true
}()
if !s.Config.Server.Virtual {
ch := make(chan os.Signal)
<-ch
s.Close()
}
}
return
}
@@ -201,25 +208,6 @@ func (s *Framework) closeServer() error {
return s.HTTPServer.Close()
}
// justServe initializes the whole framework but server doesn't listens to a specific net.Listener
func (s *Framework) justServe(optionalAddr ...string) *Server {
s.HTTPServer.Config = &s.Config.Server
if len(optionalAddr) > 0 {
s.HTTPServer.Config.ListeningAddr = optionalAddr[0]
}
s.initialize()
s.Plugins.DoPreListen(s)
s.HTTPServer.SetHandler(s.mux)
s.Plugins.DoPostListen(s)
go func() {
s.Available <- true
}()
return s.HTTPServer
}
// tester returns the test framework
func (s *Framework) tester(t *testing.T) *httpexpect.Expect {
if s.testFramework == nil {