QUIC/HTTP3
Rue supports HTTP/3 via the QUIC protocol for improved performance.
Basic Usage
r := rue.Default()
r.GET("/", func(c *rue.Context) {
c.JSON(http.StatusOK, rue.H{"protocol": "HTTP/3"})
})
// Run HTTP/3 server (requires TLS)
r.RunQUIC(":443", "cert.pem", "key.pem")
Custom Configuration
config := &rue.QUICConfig{
MaxIncomingStreams: 100,
IdleTimeout: 30 * time.Second,
Enable0RTT: true,
}
r.RunQUICWithConfig(":443", "cert.pem", "key.pem", config)
Alt-Svc Header
Advertise HTTP/3 support on HTTP/1.1 or HTTP/2:
// Add Alt-Svc middleware
r.Use(rue.AltSvc(":443"))
// Run both HTTP/2 and HTTP/3
go r.RunTLS(":443", "cert.pem", "key.pem")
r.RunQUIC(":443", "cert.pem", "key.pem")
Benefits of HTTP/3
- Faster connection establishment (0-RTT)
- No head-of-line blocking
- Better performance on lossy networks
- Connection migration (mobile-friendly)