Documentation ¶
Overview ¶
Package httpx provides an extended, production-ready HTTP server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct { *http.Server // MaxConnections limits the number of accepted simultaneous connections. // Defaults to 0, indicating no limit. MaxConnections int }
Server represents an HTTP server.
func NewServer ¶
NewServer creates a new HTTP server.
The addr is a TCP address in the form of "host:port" (e.g. "0.0.0.0:80") or a systemd socket name (e.g. "systemd:myapp-http"). The handler can be nil, in which case http.DefaultServeMux is used.
func NewServerTLS ¶
NewServerTLS creates a new HTTPS server.
The addr is a TCP address in the form of "host:port" (e.g. "0.0.0.0:80") or a systemd socket name (e.g. "systemd:myapp-http"). The handler can be nil, in which case http.DefaultServeMux is used.
func (*Server) ListenAndServe ¶
ListenAndServe listens on srv.Addr and calls Serve to handle incoming requests.
Accepted connections are configured to enable TCP keep-alives.
ListenAndServe always returns a non-nil error. After Shutdown or Close, the returned error is ErrServerClosed.
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS listens on srv.Addr and calls ServeTLS to handle incoming requests.
Accepted connections are configured to enable TCP keep-alives.
Filenames containing a certificate and matching private key for the server must be provided if neither the Server's TLSConfig.Certificates nor TLSConfig.GetCertificate are populated. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.
ListenAndServeTLS always returns a non-nil error. After Shutdown or Close, the returned error is ErrServerClosed.
func (*Server) Start ¶
Start starts the server, handling incoming requests.
Equivalent to ListenAndServe / ListenAndServeTLS without requiring the caller to choose, the server already knows whether TLS is enabled.
Accepted connections are configured to enable TCP keep-alives.
Start always returns a non-nil error. After Shutdown or Close, the returned error is ErrServerClosed.