Documentation
¶
Overview ¶
Package server offers a simple server with logging and configs
Index ¶
- type Logger
- type Server
- func (s *Server) Config(key string) string
- func (s *Server) ConfigBool(key string) bool
- func (s *Server) ConfigInt(key string) int64
- func (s *Server) Configuration() map[string]string
- func (s *Server) ConfiguredTLSServer(certManager *autocert.Manager) *http.Server
- func (s *Server) Fatal(format string)
- func (s *Server) Fatalf(format string, v ...interface{})
- func (s *Server) Log(message string)
- func (s *Server) Logf(format string, v ...interface{})
- func (s *Server) Mode() string
- func (s *Server) Port() int
- func (s *Server) PortString() string
- func (s *Server) Production() bool
- func (s *Server) Start() error
- func (s *Server) StartRedirectAll(p int, url string)
- func (s *Server) StartTLS(cert, key string) error
- func (s *Server) StartTLSAutocert(email string, domains string) error
- func (s *Server) Timef(format string, start time.Time, v ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger interface {
Printf(format string, args ...interface{})
}
Logger interface for a simple logger (the stdlib log pkg and the fragmenta log pkg conform)
type Server ¶
type Server struct { // Our internal logger instance Logger Logger // contains filtered or unexported fields }
Server holds the config and logger for the app
func (*Server) ConfigBool ¶
ConfigBool returns the current configuration value as bool (yes=true, no=false), or false if no value
func (*Server) ConfigInt ¶
ConfigInt returns the current configuration value as int64, or 0 if no value
func (*Server) Configuration ¶
Configuration returns the map of configuration keys to values
func (*Server) ConfiguredTLSServer ¶ added in v1.5.1
ConfiguredTLSServer returns a TLS server instance with a secure config this server has read/write timeouts set to 20 seconds, prefers server cipher suites and only uses certain accelerated curves see - https://blog.gopheracademy.com/advent-2016/exposing-go-on-the-internet/
func (*Server) Fatalf ¶
Fatalf the message with the given arguments to our internal logger, and then exits with status 1
func (*Server) PortString ¶ added in v1.5.1
PortString returns a string port suitable for passing to http.Server
func (*Server) Production ¶
Production tells the caller if this server is in production mode or not?
func (*Server) StartRedirectAll ¶ added in v1.5.1
StartRedirectAll starts redirecting from port given to the given url this should be called before StartTLS if redirecting to https
func (*Server) StartTLS ¶ added in v1.5.1
StartTLS starts an https server on the given port with tls cert/key from config keys.
func (*Server) StartTLSAutocert ¶ added in v1.5.1
StartTLSAutocert starts an https server on the given port by requesting certs from an ACME provider. The server must be on a public IP which matches the DNS for the domains.
Directories
¶
Path | Synopsis |
---|---|
Package log provides a simple file and console log
|
Package log provides a simple file and console log |
Package schedule provides a simple way to schedule functions at a time or interval Package schedule provides a simple way to schedule functions at a time or interval
|
Package schedule provides a simple way to schedule functions at a time or interval Package schedule provides a simple way to schedule functions at a time or interval |