mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2024-12-22 07:28:00 +00:00
Use pointers to proper server initializing handling
This commit is contained in:
parent
e60d1ae5b7
commit
8783db018b
@ -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,
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user