rackup 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rackup/handler/webrick.rb +32 -6
- data/lib/rackup/server.rb +2 -2
- data/lib/rackup/version.rb +1 -1
- data/readme.md +18 -0
- data/releases.md +4 -0
- metadata +4 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18162c3f490c041f7b861caf10d48fcd77e81a5e209dbabb1b3f7ec09ccd5145
|
|
4
|
+
data.tar.gz: 92e5b171f36c54799a05ef413acef33128805fac66c082272a1548aca2234f02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8bbd6a449a64bf48fba176d81c61f13e8eab2888853576effaa8ebf85e9579798ad2069655d9ac123322aafed5a2656bd0bd83f39e53558119e3827310fce3f6
|
|
7
|
+
data.tar.gz: d56e025ca3edfa363e94a566e356629b306c46c3490d91e7cf70a6d77d37fc4c20da30337a6c66103eccf32e71a6182c989850d965dce163b3a3566ff1faa83c
|
|
@@ -16,6 +16,19 @@ require_relative '../stream'
|
|
|
16
16
|
module Rackup
|
|
17
17
|
module Handler
|
|
18
18
|
class WEBrick < ::WEBrick::HTTPServlet::AbstractServlet
|
|
19
|
+
# A WEBrick HTTPServer subclass that invokes the Rack app directly,
|
|
20
|
+
# bypassing the mount table and default OPTIONS * handling.
|
|
21
|
+
class Server < ::WEBrick::HTTPServer
|
|
22
|
+
def initialize(app, config)
|
|
23
|
+
super(config)
|
|
24
|
+
@handler = Handler::WEBrick.new(self, app)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def service(req, res)
|
|
28
|
+
@handler.service(req, res)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
19
32
|
def self.run(app, **options)
|
|
20
33
|
environment = ENV['RACK_ENV'] || 'development'
|
|
21
34
|
default_host = environment == 'development' ? 'localhost' : nil
|
|
@@ -28,8 +41,7 @@ module Rackup
|
|
|
28
41
|
require 'webrick/https'
|
|
29
42
|
end
|
|
30
43
|
|
|
31
|
-
@server =
|
|
32
|
-
@server.mount "/", Rackup::Handler::WEBrick, app
|
|
44
|
+
@server = Server.new(app, options)
|
|
33
45
|
yield @server if block_given?
|
|
34
46
|
@server.start
|
|
35
47
|
end
|
|
@@ -102,11 +114,25 @@ module Rackup
|
|
|
102
114
|
)
|
|
103
115
|
|
|
104
116
|
env[::Rack::QUERY_STRING] ||= ""
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
|
|
118
|
+
# Handle OPTIONS * requests which have no path
|
|
119
|
+
if req.unparsed_uri == "*"
|
|
120
|
+
env[::Rack::PATH_INFO] = "*"
|
|
121
|
+
env[::Rack::REQUEST_PATH] = "*"
|
|
122
|
+
|
|
123
|
+
# Ensure SERVER_NAME and SERVER_PORT are set from server config
|
|
124
|
+
# (WEBrick allows these to be nil for OPTIONS * requests)
|
|
125
|
+
# See https://github.com/ruby/webrick/pull/182 for a proper fix.
|
|
126
|
+
env[::Rack::SERVER_NAME] ||= @server[:ServerName] || @server[:BindAddress] || "localhost"
|
|
127
|
+
env[::Rack::SERVER_PORT] ||= (@server[:Port] || 80).to_s
|
|
128
|
+
else
|
|
129
|
+
unless env[::Rack::PATH_INFO] == ""
|
|
130
|
+
# Strip the script name prefix from the path to get path info
|
|
131
|
+
script_name_length = env[::Rack::SCRIPT_NAME].length
|
|
132
|
+
env[::Rack::PATH_INFO] = req.request_uri.path[script_name_length..-1] || ""
|
|
133
|
+
end
|
|
134
|
+
env[::Rack::REQUEST_PATH] ||= env[::Rack::SCRIPT_NAME] + env[::Rack::PATH_INFO]
|
|
108
135
|
end
|
|
109
|
-
env[::Rack::REQUEST_PATH] ||= [env[::Rack::SCRIPT_NAME], env[::Rack::PATH_INFO]].join
|
|
110
136
|
|
|
111
137
|
status, headers, body = @app.call(env)
|
|
112
138
|
begin
|
data/lib/rackup/server.rb
CHANGED
|
@@ -170,14 +170,14 @@ module Rackup
|
|
|
170
170
|
# This method can be used to very easily launch a CGI application, for
|
|
171
171
|
# example:
|
|
172
172
|
#
|
|
173
|
-
#
|
|
173
|
+
# Rackup::Server.start(
|
|
174
174
|
# :app => lambda do |e|
|
|
175
175
|
# [200, {'content-type' => 'text/html'}, ['hello world']]
|
|
176
176
|
# end,
|
|
177
177
|
# :server => 'cgi'
|
|
178
178
|
# )
|
|
179
179
|
#
|
|
180
|
-
# Further options available here are documented on
|
|
180
|
+
# Further options available here are documented on Rackup::Server#initialize
|
|
181
181
|
def self.start(options = nil)
|
|
182
182
|
new(options).start
|
|
183
183
|
end
|
data/lib/rackup/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -24,6 +24,24 @@ $ rackup
|
|
|
24
24
|
|
|
25
25
|
Your application should now be available locally, typically `http://localhost:9292`.
|
|
26
26
|
|
|
27
|
+
### Server Handler
|
|
28
|
+
|
|
29
|
+
You can also use `Rackup::Handler` to start a server programmatically:
|
|
30
|
+
|
|
31
|
+
``` ruby
|
|
32
|
+
require 'rackup'
|
|
33
|
+
|
|
34
|
+
# Use the default server:
|
|
35
|
+
handler = Rackup::Handler.default
|
|
36
|
+
handler.run(app, **options)
|
|
37
|
+
|
|
38
|
+
# Use a specific server:
|
|
39
|
+
handler = Rackup::Handler.get('puma')
|
|
40
|
+
handler.run(app, **options)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Do not require specific handlers or assume they will exist/work. Instead, use the `default` method to get the best available handler.
|
|
44
|
+
|
|
27
45
|
## (Soft) Deprecation
|
|
28
46
|
|
|
29
47
|
For a long time, `rackup` (the executable and implementation) was part of `rack`, and `webrick` was the default server, included with Ruby. It made it easy to run a Rack application without having to worry about the details of the server - great for documentation and demos.
|
data/releases.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. For info on how to format all future additions to this file please reference [Keep A Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## v2.2.1
|
|
6
|
+
|
|
7
|
+
- Try to require `webrick` and `rackup/handler/webrick` by default, for compatibility with code that expects them to be available.
|
|
8
|
+
|
|
5
9
|
## v2.2.0
|
|
6
10
|
|
|
7
11
|
- Remove old rack shims.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rackup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -64,10 +64,9 @@ authors:
|
|
|
64
64
|
- Wyatt Pan
|
|
65
65
|
- Yehuda Katz
|
|
66
66
|
- Zachary Scott
|
|
67
|
-
autorequire:
|
|
68
67
|
bindir: bin
|
|
69
68
|
cert_chain: []
|
|
70
|
-
date:
|
|
69
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
71
70
|
dependencies:
|
|
72
71
|
- !ruby/object:Gem::Dependency
|
|
73
72
|
name: rack
|
|
@@ -83,8 +82,6 @@ dependencies:
|
|
|
83
82
|
- - ">="
|
|
84
83
|
- !ruby/object:Gem::Version
|
|
85
84
|
version: '3'
|
|
86
|
-
description:
|
|
87
|
-
email:
|
|
88
85
|
executables:
|
|
89
86
|
- rackup
|
|
90
87
|
extensions: []
|
|
@@ -107,9 +104,9 @@ homepage: https://github.com/rack/rackup
|
|
|
107
104
|
licenses:
|
|
108
105
|
- MIT
|
|
109
106
|
metadata:
|
|
107
|
+
changelog_uri: https://github.com/rack/rackup/blob/main/releases.md
|
|
110
108
|
rubygems_mfa_required: 'true'
|
|
111
109
|
source_code_uri: https://github.com/rack/rackup.git
|
|
112
|
-
post_install_message:
|
|
113
110
|
rdoc_options: []
|
|
114
111
|
require_paths:
|
|
115
112
|
- lib
|
|
@@ -124,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
121
|
- !ruby/object:Gem::Version
|
|
125
122
|
version: '0'
|
|
126
123
|
requirements: []
|
|
127
|
-
rubygems_version: 3.
|
|
128
|
-
signing_key:
|
|
124
|
+
rubygems_version: 3.6.9
|
|
129
125
|
specification_version: 4
|
|
130
126
|
summary: A general server command for Rack applications.
|
|
131
127
|
test_files: []
|