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
}
func NewQuicServer(ctx context.Context, tlsServer *TLSServer) QuicServer {
return QuicServer{
func NewQuicServer(ctx context.Context, tlsServer *TLSServer) *QuicServer {
return &QuicServer{
tlsServer: tlsServer,
ctx: ctx,
}

View File

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

View File

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

View File

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