added server module

This commit is contained in:
2025-12-18 12:36:29 -05:00
parent 528778753c
commit cd77794651
7 changed files with 449 additions and 0 deletions

34
server/options.go Normal file
View File

@@ -0,0 +1,34 @@
package server
import (
"log/slog"
"time"
"github.com/go-chi/chi/v5"
)
type Option func(*Server)
func WithLogger(logger *slog.Logger) Option {
return func(server *Server) { server.Log = logger }
}
func WithRouter(router chi.Router) Option {
return func(server *Server) { server.Router = router }
}
func WithShutdownTimeout(d time.Duration) Option {
return func(s *Server) { s.shutdownTimeout = d }
}
func WithReadTimeout(d time.Duration) Option {
return func(server *Server) { server.readTimeout = d }
}
func WithWriteTimeout(d time.Duration) Option {
return func(server *Server) { server.writeTimeout = d }
}
func WithIdleTimeout(d time.Duration) Option {
return func(server *Server) { server.idleTimeout = d }
}