rack-cgi 0.4.0 → 0.4.1
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/README.md +32 -0
- data/lib/rack/cgi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c8f416beeb63d142ee0091fb5672942301ee27
|
4
|
+
data.tar.gz: 53b455b7dcb638045c829240941386eb984f8f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bda537112fe3ab5a0c5bc1a448dc878f2c8ea3cd8356f73ccbe31470f8f78376228d773e70e359afa0a7fc70dc306cbd4072a65f7431afae3ef21d810b2fe8b
|
7
|
+
data.tar.gz: e73d77341b25009a7dd41e0d67d7b5662a7381a743144200e29e8abc56b479fa2e65fb08be86d15719739a76555d1a0d1826aea3e16b1166511b6737e2988817
|
data/README.md
CHANGED
@@ -64,6 +64,38 @@ You can use following code to open this feature.
|
|
64
64
|
|
65
65
|
use Rack::CGI, ..., dir_redirect: true, ...
|
66
66
|
|
67
|
+
### Use Rack::CGI in Rails project
|
68
|
+
|
69
|
+
Originally I intended to write a project named rails-cgi.
|
70
|
+
But it's so trouble, and run Rack app in rails is not very complex.
|
71
|
+
So I give up rails-cgi.
|
72
|
+
|
73
|
+
1. Create a cgi controller
|
74
|
+
|
75
|
+
$ rails g controller cgi
|
76
|
+
|
77
|
+
2. Create a Rack Application in CgiController
|
78
|
+
|
79
|
+
# You can changed arguments as you want
|
80
|
+
CGI = Rack::Builder.new do
|
81
|
+
use Rack::CGI, cgi_path: 'cgi', index: ['index.cgi', 'index.php'], Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
|
82
|
+
use Rack::Static, urls: ['/'], root: 'cgi'
|
83
|
+
run proc{ |env| raise ActionController::RoutingError, env['PATH_INFO'] + " not found!" }
|
84
|
+
end
|
85
|
+
|
86
|
+
3. Call Rack App in rails controller
|
87
|
+
|
88
|
+
# add an action to controller
|
89
|
+
def cgi
|
90
|
+
[self.status, self.response.headers, self.response_body] = CGI.call env
|
91
|
+
end
|
92
|
+
# of course, you can add decoration code here, such as call rails layout
|
93
|
+
|
94
|
+
4. Add route
|
95
|
+
|
96
|
+
# add follow to config/routes.rb
|
97
|
+
get '/cgi-bin/*path' => 'cgi#cgi'
|
98
|
+
|
67
99
|
TODO
|
68
100
|
----
|
69
101
|
|
data/lib/rack/cgi/version.rb
CHANGED