Class: Webhookdb::Service::Middleware::CopyCookieToExplicitHeader
- Inherits:
-
Object
- Object
- Webhookdb::Service::Middleware::CopyCookieToExplicitHeader
- Defined in:
- lib/webhookdb/service/middleware.rb
Overview
In browser environments, they can’t access the Cookie header for API requests, and it doesn’t always get the automatic binding behavior we want (for example fetches made from WASM). So copy it into something we can access. This must be before the Rack session middleware.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ CopyCookieToExplicitHeader
constructor
A new instance of CopyCookieToExplicitHeader.
Constructor Details
#initialize(app) ⇒ CopyCookieToExplicitHeader
Returns a new instance of CopyCookieToExplicitHeader.
84 85 86 |
# File 'lib/webhookdb/service/middleware.rb', line 84 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/webhookdb/service/middleware.rb', line 88 def call(env) env["HTTP_COOKIE"] = env[Webhookdb::Service::AUTH_TOKEN_HTTP] if env[Webhookdb::Service::AUTH_TOKEN_HTTP] status, headers, body = @app.call(env) headers[Webhookdb::Service::AUTH_TOKEN_HEADER] = headers["Set-Cookie"] if headers["Set-Cookie"] return status, headers, body end |