Maint: http proxy server constructor returns struct
This commit is contained in:
@@ -9,11 +9,7 @@ import (
|
|||||||
"github.com/qdm12/golibs/logging"
|
"github.com/qdm12/golibs/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server interface {
|
type Server struct {
|
||||||
Run(ctx context.Context, errorCh chan<- error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type server struct {
|
|
||||||
address string
|
address string
|
||||||
handler http.Handler
|
handler http.Handler
|
||||||
logger logging.Logger
|
logger logging.Logger
|
||||||
@@ -21,9 +17,9 @@ type server struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context, address string, logger logging.Logger,
|
func New(ctx context.Context, address string, logger logging.Logger,
|
||||||
stealth, verbose bool, username, password string) Server {
|
stealth, verbose bool, username, password string) *Server {
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
return &server{
|
return &Server{
|
||||||
address: address,
|
address: address,
|
||||||
handler: newHandler(ctx, wg, logger, stealth, verbose, username, password),
|
handler: newHandler(ctx, wg, logger, stealth, verbose, username, password),
|
||||||
logger: logger,
|
logger: logger,
|
||||||
@@ -31,7 +27,7 @@ func New(ctx context.Context, address string, logger logging.Logger,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) Run(ctx context.Context, errorCh chan<- error) {
|
func (s *Server) Run(ctx context.Context, errorCh chan<- error) {
|
||||||
server := http.Server{Addr: s.address, Handler: s.handler}
|
server := http.Server{Addr: s.address, Handler: s.handler}
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
|
|||||||
Reference in New Issue
Block a user