diff options
Diffstat (limited to 'pkg/srv/config.go')
| -rw-r--r-- | pkg/srv/config.go | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/pkg/srv/config.go b/pkg/srv/config.go deleted file mode 100644 index c02a9c7..0000000 --- a/pkg/srv/config.go +++ /dev/null @@ -1,42 +0,0 @@ -package srv - -import ( - "crypto/tls" - "net/http" -) - -type Option func(*Config) - -type Config struct { - BindAddress string - Mux http.Handler - TLS *tls.Config -} - -func WithMux(mux http.Handler) Option { - return func(config *Config) { - config.Mux = mux - } -} - -func NewConfig(addr string, options ...Option) *Config { - if addr == "" { - addr = ":0" - } - - c := &Config{ - BindAddress: addr, - Mux: http.DefaultServeMux, - } - for _, option := range options { - option(c) - } - return c -} - -func (c *Config) Run(server *http.Server) error { - if c.TLS != nil { - return server.ListenAndServeTLS("", "") - } - return server.ListenAndServe() -} |
