ytdl-web/pkg/server/options.go

33 lines
538 B
Go
Raw Permalink Normal View History

2023-08-14 18:14:08 -04:00
package server
import "golang.org/x/exp/slog"
type Options struct {
2023-08-14 18:14:08 -04:00
ListenAddr string
ListenPort int
Logger *slog.Logger
}
func DefaultOptions() *Options {
return &Options{
2023-08-14 18:14:08 -04:00
ListenAddr: "127.0.0.1",
ListenPort: 8080,
Logger: slog.Default(),
}
}
func (o *Options) WithListenAddr(addr string) *Options {
2023-08-14 18:14:08 -04:00
o.ListenAddr = addr
return o
}
func (o *Options) WithListenPort(port int) *Options {
2023-08-14 18:14:08 -04:00
o.ListenPort = port
return o
}
func (o *Options) WithLogger(logger *slog.Logger) *Options {
2023-08-14 18:14:08 -04:00
o.Logger = logger
return o
}