Skip to content

Commit

Permalink
Add NewWithConfig init function to api/server.go (#192)
Browse files Browse the repository at this point in the history
* add NewWithConfig function

* cleanup
  • Loading branch information
fearful-symmetry committed Apr 3, 2024
1 parent d221ab4 commit e2cb821
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e2cb821

Please sign in to comment.