Class: HTM::Sinatra::Middleware
- Inherits:
-
Object
- Object
- HTM::Sinatra::Middleware
- Defined in:
- lib/htm/integrations/sinatra.rb
Overview
Rack middleware for HTM connection management
Ensures database connections are properly managed across requests. With Sequel’s fiber-safe connection pooling, this is largely automatic.
Class Method Summary collapse
-
.store_config! ⇒ Object
Store the connection config at startup (called from register_htm).
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
111 112 113 114 |
# File 'lib/htm/integrations/sinatra.rb', line 111 def initialize(app, = {}) @app = app @options = end |
Class Method Details
.store_config! ⇒ Object
Store the connection config at startup (called from register_htm)
128 129 130 131 |
# File 'lib/htm/integrations/sinatra.rb', line 128 def self.store_config! # With Sequel, connection is established globally via HTM::SequelConfig # No additional per-request config storage needed end |
Instance Method Details
#call(env) ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/htm/integrations/sinatra.rb', line 116 def call(env) # Ensure connection is available ensure_connection! # Process request status, headers, body = @app.call(env) # Return response [status, headers, body] end |