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