Documentation
¶
Index ¶
- func TCP(addr string, handler http.Handler) error
- func TLS(addr string, handler http.Handler, certFile, keyFile string) error
- func Unix(unix string, handler http.Handler) error
- func UnixTLS(unix string, handler http.Handler, certFile, keyFile string) error
- type Server
- func (s *Server) ReadBytes() int64
- func (s *Server) Reload() error
- func (s *Server) Run() error
- func (s *Server) RunTLS(certFile, keyFile string) error
- func (s *Server) Serve(tls bool) (err error)
- func (s *Server) SetLogger(logger *log.Logger)
- func (s *Server) SetReload(d time.Duration)
- func (s *Server) WriteBytes() int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
type Server struct {
*http.Server
*log.Logger
Unix string
Host string
Port string
// contains filtered or unexported fields
}
Server defines parameters for running an HTTP or HTTPS server.
func (*Server) ReadBytes ¶ added in v0.1.81
ReadBytes returns the total number of bytes read by the listener.
func (*Server) Reload ¶ added in v0.1.81
Reload rotates server's log and reloads TLS certificates if applicable.
func (*Server) RunTLS ¶
RunTLS starts an HTTPS server using the provided certificate and key files. Certificates are automatically reloaded based on the reload interval.
func (*Server) Serve ¶ added in v0.1.81
Serve starts the HTTP or HTTPS server and handles graceful shutdown signals.
It listens on either a Unix domain socket (if s.Unix is set) or a TCP address. When receiving SIGHUP, the server reloads configuration or certificates. When receiving SIGINT/SIGTERM, it gracefully shuts down all connections.
func (*Server) SetLogger ¶
SetLogger sets a custom logger for both the Server and its internal http.Server.
func (*Server) SetReload ¶
SetReload defines the certificate reload interval. Default is 24 hours if not set explicitly.
func (*Server) WriteBytes ¶ added in v0.1.81
WriteBytes returns the total number of bytes written by the listener.