Compression

Rue supports Gzip and Brotli compression with automatic content negotiation.

Usage

// Auto-select best compression (prefers Brotli)
r.Use(rue.Compress())

// Gzip only
r.Use(rue.Gzip())

// Brotli only
r.Use(rue.Brotli())

How It Works

The compression middleware:

  1. Checks the Accept-Encoding header
  2. Selects the best supported algorithm
  3. Compresses the response body
  4. Sets the Content-Encoding header

Benchmarks

AlgorithmTimeCompression Ratio
Gzip~43µsGood
Brotli~18µsBetter