all repos — homestead @ c641b47bd01a0f1fbf3dc7749594ceec373e794c

Code for my website

enable serving via custom net.Listener

Alan Pearce
commit

c641b47bd01a0f1fbf3dc7749594ceec373e794c

parent

7487bfebd61c1c4290cd12c7a4cc1dff56b3e239

1 file changed, 11 insertions(+), 1 deletion(-)

changed files
M domain/web/server/server.godomain/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")) }