Skip to content

Commit

Permalink
Use pointers to proper server initializing handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarrillo committed Mar 20, 2023
1 parent e60d1ae commit 8783db0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions server/quic_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
14 changes: 7 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
}
}

Expand Down
4 changes: 2 additions & 2 deletions server/tcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions server/tls_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 8783db0

Please sign in to comment.