mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-21 22:36:31 +00:00
6529549289
* implement custom http handler interface * implement trace_id * normalize http method spacing for consistent logs * fix failing test * fix linter errors * cleanup old dead code * more route cleanup * cleanup some inconsistent errors * update and generate code * make taskfile more consistent * update task calls * run tidy * drop `@` tag for version * use relative paths * tidy * fix auto-setting variables * update build paths * add contributing guide * tidy
54 lines
950 B
Go
54 lines
950 B
Go
package server
|
|
|
|
import "time"
|
|
|
|
type Option = func(s *Server) error
|
|
|
|
func WithMiddleware(mw ...Middleware) Option {
|
|
return func(s *Server) error {
|
|
s.mw = append(s.mw, mw...)
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithWorker(w Worker) Option {
|
|
return func(s *Server) error {
|
|
s.Worker = w
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithHost(host string) Option {
|
|
return func(s *Server) error {
|
|
s.Host = host
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithPort(port string) Option {
|
|
return func(s *Server) error {
|
|
s.Port = port
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithReadTimeout(seconds int) Option {
|
|
return func(s *Server) error {
|
|
s.readTimeout = time.Duration(seconds) * time.Second
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithWriteTimeout(seconds int) Option {
|
|
return func(s *Server) error {
|
|
s.writeTimeout = time.Duration(seconds) * time.Second
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func WithIdleTimeout(seconds int) Option {
|
|
return func(s *Server) error {
|
|
s.idleTimeout = time.Duration(seconds) * time.Second
|
|
return nil
|
|
}
|
|
}
|