Class: Hanami::EarlyHints Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/early_hints.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

HTTP/2 Early Hints Rack middleware

It sends extra responses before the main response is sent. These extra responses are HTTP/2 Early Hints (103). They specify the web assets (javascripts, stylesheets, etc..) to be “pushed”, so modern browsers pre-fetch them in parallel with the main HTTP response.

Defined Under Namespace

Classes: NotSupportedByServerError

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ EarlyHints

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of EarlyHints.

Since:

  • 1.2.0



28
29
30
# File 'lib/hanami/early_hints.rb', line 28

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array, Rack::Response

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a Rack response.

Parameters:

  • env (Hash)

    Rack env

Returns:

  • (Array, Rack::Response)

    a Rack response

Raises:

Since:

  • 1.2.0



41
42
43
44
45
# File 'lib/hanami/early_hints.rb', line 41

def call(env)
  @app.call(env).tap do
    send_early_hints(env)
  end
end