Class: Datastar::Compressor::Brotli
- Inherits:
-
Object
- Object
- Datastar::Compressor::Brotli
- Defined in:
- lib/datastar/compressor/brotli.rb
Overview
Brotli compressor — built once at config time, reused across requests. Eagerly requires the brotli gem; raises LoadError at boot if missing.
Defined Under Namespace
Classes: CompressedSocket
Instance Attribute Summary collapse
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
Instance Method Summary collapse
-
#initialize(options) ⇒ Brotli
constructor
A new instance of Brotli.
- #prepare_response(response) ⇒ Object
- #wrap_socket(socket) ⇒ Object
Constructor Details
#initialize(options) ⇒ Brotli
Returns a new instance of Brotli.
12 13 14 15 16 |
# File 'lib/datastar/compressor/brotli.rb', line 12 def initialize() @options = .freeze @encoding = :br freeze end |
Instance Attribute Details
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
10 11 12 |
# File 'lib/datastar/compressor/brotli.rb', line 10 def encoding @encoding end |
Instance Method Details
#prepare_response(response) ⇒ Object
18 19 20 21 |
# File 'lib/datastar/compressor/brotli.rb', line 18 def prepare_response(response) response.headers['Content-Encoding'] = 'br' response.headers['Vary'] = 'Accept-Encoding' end |
#wrap_socket(socket) ⇒ Object
23 24 25 |
# File 'lib/datastar/compressor/brotli.rb', line 23 def wrap_socket(socket) CompressedSocket.new(socket, @options) end |