From e2cb821902838a3eeabc781dcdb11ca5a603b643 Mon Sep 17 00:00:00 2001 From: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:05:27 -0700 Subject: [PATCH] Add NewWithConfig init function to api/server.go (#192) * add NewWithConfig function * cleanup --- api/server.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/server.go b/api/server.go index c7acdda3..d5caf81b 100644 --- a/api/server.go +++ b/api/server.go @@ -56,6 +56,16 @@ func New(log *logp.Logger, mux *http.ServeMux, c *config.C) (*Server, error) { if err != nil { return nil, err } + return new(log, mux, cfg) +} + +// NewFromConfig creates a new API server from the given Config object. +func NewFromConfig(log *logp.Logger, mux *http.ServeMux, cfg Config) (*Server, error) { + return new(log, mux, cfg) +} + +// new creates the server from a config struct +func new(log *logp.Logger, mux *http.ServeMux, cfg Config) (*Server, error) { srv := &http.Server{ReadHeaderTimeout: cfg.Timeout} l, err := makeListener(cfg) if err != nil {