MCPcopy Index your code
hub / github.com/ContainerSSH/ContainerSSH / NewServer

Function NewServer

http/server_factory.go:13–47  ·  view source on GitHub ↗

NewServer creates a new HTTP server with the given configuration and calling the provided handler.

(
	name string,
	config config.HTTPServerConfiguration,
	handler goHttp.Handler,
	logger log.Logger,
	onReady func(string),
)

Source from the content-addressed store, hash-verified

11
12// NewServer creates a new HTTP server with the given configuration and calling the provided handler.
13func NewServer(
14 name string,
15 config config.HTTPServerConfiguration,
16 handler goHttp.Handler,
17 logger log.Logger,
18 onReady func(string),
19) (Server, error) {
20 if handler == nil {
21 panic("BUG: no handler provided to http.NewServer")
22 }
23 if logger == nil {
24 panic("BUG: no logger provided to http.NewServer")
25 }
26
27 certs, err := config.ValidateWithCerts()
28 if err != nil {
29 return nil, err
30 }
31
32 var tlsConfig *tls.Config
33 if certs.Cert != nil {
34 tlsConfig = createServerTLSConfig(config, certs)
35 }
36
37 return &server{
38 name: name,
39 lock: &sync.Mutex{},
40 handler: handler,
41 config: config,
42 tlsConfig: tlsConfig,
43 srv: nil,
44 goLogger: log.NewGoLogWriter(logger),
45 onReady: onReady,
46 }, nil
47}
48
49func createServerTLSConfig(config config.HTTPServerConfiguration, certs *config.HTTPServerCerts) *tls.Config {
50 // We let users configure the minimum TLS version, so we don't need gosec here.

Callers 4

NewServerFunction · 0.92
NewOAuth2ClientFunction · 0.92
OIDCServerFunction · 0.92
mainFunction · 0.92

Calls 3

NewGoLogWriterFunction · 0.92
createServerTLSConfigFunction · 0.85
ValidateWithCertsMethod · 0.45

Tested by

no test coverage detected