func (cfg Config) NewServer(p Parameters) (*Server, error) {
	if err := cfg.validate(p); err != nil {
		return nil, fmt.Errorf("creating server: validation: %w", err)
	}
	template, err := p.parseTemplate()
	if err != nil {
		return nil, err
	}
	monitor := runtimeMonitor{
		hasTLS: cfg.validHTTPAddr(),
	}
	httpAddr := fmt.Sprintf(":%d", cfg.HTTPPort)
	httpsAddr := fmt.Sprintf(":%d", cfg.HTTPSPort)
	httpsRedirectHandler := httpsRedirectHandler(cfg.HTTPSPort)
	httpHandler := cfg.httpHandler(httpsRedirectHandler)
	httpsHandler := cfg.httpsHandler(httpHandler, httpsRedirectHandler, p, template, monitor)
	s := Server{
		log:   p.Logger,
		lobby: p.Lobby,
		HTTPServer: &http.Server{
			Addr:         httpAddr,
			Handler:      httpHandler,
			ReadTimeout:  60 * time.Second,
			WriteTimeout: 60 * time.Second,
		},
		HTTPSServer: &http.Server{
			Addr:         httpsAddr,
			Handler:      httpsHandler,
			ReadTimeout:  60 * time.Second,
			WriteTimeout: 60 * time.Second,
		},
		Config: cfg,
	}
	return &s, nil
}
// NewServer creates a Server from the Config
NewServer creates a Server from the Config
// NewServer creates a Server from the Config
func (cfg Config) NewServer(p Parameters) (*Server, error) {
	if err := cfg.validate(p); err != nil {
		return nil, fmt.Errorf("creating server: validation: %w", err)
	}
	template, err := p.parseTemplate()
	if err != nil {
		return nil, err
	}
	monitor := runtimeMonitor{
		hasTLS: cfg.validHTTPAddr(),
	}
	httpAddr := fmt.Sprintf(":%d", cfg.HTTPPort)
	httpsAddr := fmt.Sprintf(":%d", cfg.HTTPSPort)
	httpsRedirectHandler := httpsRedirectHandler(cfg.HTTPSPort)
	httpHandler := cfg.httpHandler(httpsRedirectHandler)
	httpsHandler := cfg.httpsHandler(httpHandler, httpsRedirectHandler, p, template, monitor)
	s := Server{
		log:   p.Logger,
		lobby: p.Lobby,
		HTTPServer: &http.Server{
			Addr:         httpAddr,
			Handler:      httpHandler,
			ReadTimeout:  60 * time.Second,
			WriteTimeout: 60 * time.Second,
		},
		HTTPSServer: &http.Server{
			Addr:         httpsAddr,
			Handler:      httpsHandler,
			ReadTimeout:  60 * time.Second,
			WriteTimeout: 60 * time.Second,
		},
		Config: cfg,
	}
	return &s, nil
}
func ( cfg Config ) NewServer ( p Parameters ) ( * Server , error ) { if err := cfg . validate ( p ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } template , err := p . parseTemplate ( ) if err != nil { return nil , err } monitor := runtimeMonitor { hasTLS : cfg . validHTTPAddr ( ) , } httpAddr := fmt . Sprintf ( " " , cfg . HTTPPort ) httpsAddr := fmt . Sprintf ( " " , cfg . HTTPSPort ) httpsRedirectHandler := httpsRedirectHandler ( cfg . HTTPSPort ) httpHandler := cfg . httpHandler ( httpsRedirectHandler ) httpsHandler := cfg . httpsHandler ( httpHandler , httpsRedirectHandler , p , template , monitor ) s := Server { log : p . Logger , lobby : p . Lobby , HTTPServer : & http . Server { Addr : httpAddr , Handler : httpHandler , ReadTimeout : 60 * time . Second , WriteTimeout : 60 * time . Second , } , HTTPSServer : & http . Server { Addr : httpsAddr , Handler : httpsHandler , ReadTimeout : 60 * time . Second , WriteTimeout : 60 * time . Second , } , Config : cfg , } return & s , nil }
NewServer creates a Server from the Config
NewServer creates a Server from the Config