Use pointers to proper server initializing handling

This commit is contained in:
Daniel Carrillo 2023-03-20 17:38:29 +01:00
parent e60d1ae5b7
commit 8783db018b
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
4 changed files with 13 additions and 13 deletions

View File

@ -15,8 +15,8 @@ type QuicServer struct {
ctx context.Context ctx context.Context
} }
func NewQuicServer(ctx context.Context, tlsServer *TLSServer) QuicServer { func NewQuicServer(ctx context.Context, tlsServer *TLSServer) *QuicServer {
return QuicServer{ return &QuicServer{
tlsServer: tlsServer, tlsServer: tlsServer,
ctx: ctx, ctx: ctx,
} }

View File

@ -24,9 +24,9 @@ type Factory struct {
} }
func Setup(ctx context.Context, handler http.Handler) *Factory { func Setup(ctx context.Context, handler http.Handler) *Factory {
var tcpServer TCPServer var tcpServer *TCPServer
var tlsServer TLSServer var tlsServer *TLSServer
var quicServer QuicServer var quicServer *QuicServer
if setting.App.BindAddress != "" { if setting.App.BindAddress != "" {
tcpServer = NewTCPServer(ctx, &handler) tcpServer = NewTCPServer(ctx, &handler)
@ -35,14 +35,14 @@ func Setup(ctx context.Context, handler http.Handler) *Factory {
if setting.App.TLSAddress != "" { if setting.App.TLSAddress != "" {
tlsServer = NewTLSServer(ctx, &handler) tlsServer = NewTLSServer(ctx, &handler)
if setting.App.EnableHTTP3 { if setting.App.EnableHTTP3 {
quicServer = NewQuicServer(ctx, &tlsServer) quicServer = NewQuicServer(ctx, tlsServer)
} }
} }
return &Factory{ return &Factory{
tcpServer: &tcpServer, tcpServer: tcpServer,
tlsServer: &tlsServer, tlsServer: tlsServer,
quicServer: &quicServer, quicServer: quicServer,
} }
} }

View File

@ -15,8 +15,8 @@ type TCPServer struct {
ctx context.Context ctx context.Context
} }
func NewTCPServer(ctx context.Context, handler *http.Handler) TCPServer { func NewTCPServer(ctx context.Context, handler *http.Handler) *TCPServer {
return TCPServer{ return &TCPServer{
handler: handler, handler: handler,
ctx: ctx, ctx: ctx,
} }

View File

@ -15,8 +15,8 @@ type TLSServer struct {
ctx context.Context ctx context.Context
} }
func NewTLSServer(ctx context.Context, handler *http.Handler) TLSServer { func NewTLSServer(ctx context.Context, handler *http.Handler) *TLSServer {
return TLSServer{ return &TLSServer{
handler: handler, handler: handler,
ctx: ctx, ctx: ctx,
} }