File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -327,6 +327,10 @@ def parse_options
327327 end
328328
329329 @config = Puma ::Configuration . new @options
330+
331+ # Advertise the Configuration
332+ Puma . cli_config = @config
333+
330334 @config . load
331335 end
332336
Original file line number Diff line number Diff line change 11module Puma
2+
3+ # The CLI exports it's Configuration object here to allow
4+ # apps to pick it up. An app needs to use it conditionally though
5+ # since it is not set if the app is launched via another
6+ # mechanism than the CLI class.
7+
8+ class << self
9+ attr_accessor :cli_config
10+ end
11+
212 class Configuration
313 DefaultRackup = "config.ru"
414
@@ -44,6 +54,19 @@ def load
4454 end
4555 end
4656
57+ # Injects the Configuration object into the env
58+ class ConfigMiddleware
59+ def initialize ( config , app )
60+ @config = config
61+ @app = app
62+ end
63+
64+ def call ( env )
65+ env [ Const ::PUMA_CONFIG ] = @config
66+ @app . call ( env )
67+ end
68+ end
69+
4770 # Load the specified rackup file, pull an options from
4871 # the rackup file, and set @app.
4972 #
@@ -72,7 +95,7 @@ def app
7295 app = Rack ::CommonLogger . new ( app , logger )
7396 end
7497
75- return app
98+ return ConfigMiddleware . new ( self , app )
7699 end
77100
78101 def setup_random_token
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ module Const
119119 RACK_URL_SCHEME = "rack.url_scheme" . freeze
120120 RACK_AFTER_REPLY = "rack.after_reply" . freeze
121121 PUMA_SOCKET = "puma.socket" . freeze
122+ PUMA_CONFIG = "puma.config" . freeze
122123
123124 HTTP = "http" . freeze
124125 HTTPS = "https" . freeze
You can’t perform that action at this time.
0 commit comments