Add ability to build an unstarted ghttp server
diff --git a/ghttp/test_server.go b/ghttp/test_server.go index 71cd341..1e5afc8 100644 --- a/ghttp/test_server.go +++ b/ghttp/test_server.go
@@ -138,6 +138,13 @@ return s } +// NewUnstartedServer return a new, unstarted, `*ghttp.Server`. Useful for specifying a custom listener on `server.HTTPTestServer`. +func NewUnstartedServer() *Server { + s := new() + s.HTTPTestServer = httptest.NewUnstartedServer(s) + return s +} + // NewTLSServer returns a new `*ghttp.Server` that wraps an `httptest` TLS server. The server is started automatically. func NewTLSServer() *Server { s := new() @@ -165,6 +172,11 @@ calls int } +//Start() starts an unstarted ghttp server. It is a catastrophic error to call Start more than once (thanks, httptest). +func (s *Server) Start() { + s.HTTPTestServer.Start() +} + //URL() returns a url that will hit the server func (s *Server) URL() string { return s.HTTPTestServer.URL