github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/pkg/web/options.go (about) 1 package web 2 3 import ( 4 "github.com/hellofresh/janus/pkg/api" 5 "github.com/hellofresh/janus/pkg/config" 6 ) 7 8 // Option represents the available options 9 type Option func(*Server) 10 11 // WithConfigurations sets the current configurations in memory 12 func WithConfigurations(cfgs *api.Configuration) Option { 13 return func(s *Server) { 14 s.apiHandler.Cfgs = cfgs 15 } 16 } 17 18 // WithPort sets the server port 19 func WithPort(port int) Option { 20 return func(s *Server) { 21 s.Port = port 22 } 23 } 24 25 // WithCredentials sets the credentials for the server 26 func WithCredentials(cred config.Credentials) Option { 27 return func(s *Server) { 28 s.Credentials = cred 29 } 30 } 31 32 // WithTLS sets the TLS configs for the server 33 func WithTLS(tls config.TLS) Option { 34 return func(s *Server) { 35 s.TLS = tls 36 } 37 } 38 39 // WithProfiler enables or disables profiler 40 func WithProfiler(enabled, public bool) Option { 41 return func(s *Server) { 42 s.profilingEnabled = enabled 43 s.profilingPublic = public 44 } 45 }