File tree 3 files changed +29
-1
lines changed
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,10 @@ def parse_options
327
327
end
328
328
329
329
@config = Puma ::Configuration . new @options
330
+
331
+ # Advertise the Configuration
332
+ Puma . cli_config = @config
333
+
330
334
@config . load
331
335
end
332
336
Original file line number Diff line number Diff line change 1
1
module 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
+
2
12
class Configuration
3
13
DefaultRackup = "config.ru"
4
14
@@ -44,6 +54,19 @@ def load
44
54
end
45
55
end
46
56
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
+
47
70
# Load the specified rackup file, pull an options from
48
71
# the rackup file, and set @app.
49
72
#
@@ -72,7 +95,7 @@ def app
72
95
app = Rack ::CommonLogger . new ( app , logger )
73
96
end
74
97
75
- return app
98
+ return ConfigMiddleware . new ( self , app )
76
99
end
77
100
78
101
def setup_random_token
Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ module Const
119
119
RACK_URL_SCHEME = "rack.url_scheme" . freeze
120
120
RACK_AFTER_REPLY = "rack.after_reply" . freeze
121
121
PUMA_SOCKET = "puma.socket" . freeze
122
+ PUMA_CONFIG = "puma.config" . freeze
122
123
123
124
HTTP = "http" . freeze
124
125
HTTPS = "https" . freeze
You can’t perform that action at this time.
0 commit comments