Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultTLSConfig ¶
func DefaultTLSConfig(cert tls.Certificate) *tls.Config
DefaultTLSConfig returns a TLS configuration suitable for HTTP/2.
func GenerateSelfSignedCert ¶
func GenerateSelfSignedCert() (tls.Certificate, error)
GenerateSelfSignedCert creates a self-signed certificate for testing.
Types ¶
type HTTP2Config ¶
type HTTP2Config struct {
// MaxConcurrentStreams per connection (default 250).
MaxConcurrentStreams uint32
// MaxFrameSize is the maximum frame payload size (default 16384).
MaxFrameSize uint32
// InitialWindowSize is the initial flow-control window (default 1MB).
InitialWindowSize uint32
// MaxHeaderListSize is the maximum header list size (default 1MB).
MaxHeaderListSize uint32
}
HTTP2Config holds HTTP/2-specific server settings.
type Server ¶
type Server struct {
// Addr is the TCP address to listen on (e.g. ":8443").
Addr string
// Handler handles requests. It uses the HTTP/2 RequestCtx type, which is
// also used for HTTP/1.1 requests via an automatic bridge when HTTP1Handler
// is nil. This enables a single handler for both protocols.
Handler http2.RequestHandler
// TLSConfig is the TLS configuration. Required for ListenAndServeTLS().
// Must include at least one certificate and should set NextProtos to
// []string{"h2", "http/1.1"} for HTTP/2 support.
TLSConfig *tls.Config
// ReadTimeout is the maximum duration for reading a request.
ReadTimeout time.Duration
// WriteTimeout is the maximum duration for writing a response.
WriteTimeout time.Duration
// IdleTimeout is the maximum time to wait for the next request on a keep-alive connection.
IdleTimeout time.Duration
// MaxRequestBodySize limits request body size (default 4MB).
MaxRequestBodySize int
// HTTP2 holds HTTP/2-specific settings. If nil, defaults are used.
HTTP2 *HTTP2Config
// MaxConcurrentStreams per HTTP/2 connection (default 250).
// Deprecated: use HTTP2.MaxConcurrentStreams instead.
MaxConcurrentStreams uint32
// WorkerPoolSize for HTTP/2 request processing (default: NumCPU * 256).
WorkerPoolSize int
// HTTP1Handler optionally overrides the default HTTP/1.1 handler.
// If nil, Handler is used via an automatic protocol bridge.
HTTP1Handler http1.RequestHandler
// contains filtered or unexported fields
}
Server is the main BlazeHTTP server supporting HTTP/1.1 and HTTP/2.
func (*Server) ListenAndServe ¶
ListenAndServe starts the server on the configured address using plain HTTP. Supports h2c (HTTP/2 over cleartext) via connection preface detection.
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS starts the server with TLS using the pre-configured TLSConfig. TLSConfig must be set and must contain at least one certificate.
func (*Server) ListenAndServeTLSCert ¶
func (s *Server) ListenAndServeTLSCert(cert tls.Certificate) error
ListenAndServeTLSCert starts the server with a pre-loaded TLS certificate.
func (*Server) ListenAndServeTLSFiles ¶
ListenAndServeTLSFiles starts the server with TLS using cert/key files.