added server module
This commit is contained in:
34
server/options.go
Normal file
34
server/options.go
Normal 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 }
|
||||
}
|
||||
Reference in New Issue
Block a user