33 lines
538 B
Go
33 lines
538 B
Go
package server
|
|
|
|
import "golang.org/x/exp/slog"
|
|
|
|
type Options struct {
|
|
ListenAddr string
|
|
ListenPort int
|
|
Logger *slog.Logger
|
|
}
|
|
|
|
func DefaultOptions() *Options {
|
|
return &Options{
|
|
ListenAddr: "127.0.0.1",
|
|
ListenPort: 8080,
|
|
Logger: slog.Default(),
|
|
}
|
|
}
|
|
|
|
func (o *Options) WithListenAddr(addr string) *Options {
|
|
o.ListenAddr = addr
|
|
return o
|
|
}
|
|
|
|
func (o *Options) WithListenPort(port int) *Options {
|
|
o.ListenPort = port
|
|
return o
|
|
}
|
|
|
|
func (o *Options) WithLogger(logger *slog.Logger) *Options {
|
|
o.Logger = logger
|
|
return o
|
|
}
|