enable serving via custom net.Listener
1 file changed, 11 insertions(+), 1 deletion(-)
changed files
M domain/web/server/server.go → domain/web/server/server.go
@@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "net" "net/http" "time"@@ -35,6 +36,7 @@ Development bool `conf:"-"` LiveReload *livereload.LiveReload `conf:"-"` Domains []string `conf:"-"` WildcardDomains []string `conf:"-"` + Listener net.Listener `conf:"-"` } type Server struct {@@ -111,7 +113,15 @@ IdleTimeout: IdleTimeout, Handler: top, } - if err := s.serveTCP(); !errors.Is(err, http.ErrServerClosed) { + if s.options.Listener == nil { + var err error + s.options.Listener, err = s.tcpListener() + if err != nil { + return fault.Wrap(err, fmsg.With("error creating listener")) + } + } + + if err := s.server.Serve(s.options.Listener); !errors.Is(err, http.ErrServerClosed) { return fault.Wrap(err, fmsg.With("error creating/closing server")) }