Class: Securial::Middleware::ResponseHeaders

Inherits:
Object
  • Object
show all
Defined in:
lib/securial/middleware/response_headers.rb

Overview

Rack middleware that adds Securial identification headers to responses.

This middleware enhances security transparency by clearly identifying when Securial is mounted in an application and provides developer attribution information in response headers.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ResponseHeaders

Initializes the middleware with the Rack application.

Examples:

middleware = ResponseHeaders.new(app)

Parameters:

  • app (#call)

    The Rack application to wrap



35
36
37
# File 'lib/securial/middleware/response_headers.rb', line 35

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array

Processes the request and adds Securial headers to the response.

Calls the wrapped application and then adds identification headers to the response before returning it to the client. The headers provide clear indication of Securial usage and developer attribution.

Examples:

Headers added to response

# Original response headers remain unchanged
# Additional headers added:
# X-Securial-Mounted: "true"
# X-Securial-Developer: "Aly Badawy - https://alybadawy.com | @alybadawy"

Parameters:

  • env (Hash)

    The Rack environment hash

Returns:

  • (Array)

    The Rack response array [status, headers, body] with added headers



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/securial/middleware/response_headers.rb', line 54

def call(env)
  status, headers, response = @app.call(env)

  # Indicate that Securial is mounted and active
  headers["X-Securial-Mounted"] = "true"

  # Provide developer attribution
  headers["X-Securial-Developer"] = "Aly Badawy - https://alybadawy.com | @alybadawy"

  [status, headers, response]
end