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.
92 93 94 |
# File 'lib/webhookdb/service/middleware.rb', line 92 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/webhookdb/service/middleware.rb', line 96 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 |