rack-cgi 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -43
- 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: 79b63dd716b9dcd6cd7369512c08f11e860b5838
|
4
|
+
data.tar.gz: a4334d97836b664f375fcc412f3ac32921aeb841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb7fe7f8b01088c1b68639bafa2f36ae33521df8606410b16345df0060e0f10e7f194a0db38dfbc573a4accac450a55f5b9a2475f757559ac151a1255b29da67
|
7
|
+
data.tar.gz: 4cc7cdddb15eafffcc4a0f6b7c08a3d7c733df22bc8349eaa2a51e1870489a5dee7efefdea3bbb8dc7890e12e98dbd0ee0ad69f42fb9f3972a7ea63209ec07e6
|
data/README.md
CHANGED
@@ -7,13 +7,12 @@ Usage
|
|
7
7
|
-----
|
8
8
|
|
9
9
|
Here is an example for using Rack::CGI
|
10
|
-
|
11
|
-
|
10
|
+
# config.ru
|
11
|
+
|
12
|
+
use Rack::CGI, cgi_path: 'cgi', index: 'index.cgi', Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
|
13
|
+
use Rack::Static, urls: ['/'], root: 'cgi'
|
14
|
+
run proc{ [404, {"CONTENT-TYPE" => "text/plain"}, ['404 Not Found']] }
|
12
15
|
|
13
|
-
use Rack::CGI, cgi_path: 'cgi', index: 'index.cgi', Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
|
14
|
-
use Rack::Static, urls: ['/'], root: 'cgi'
|
15
|
-
run proc{ [404, {"CONTENT-TYPE" => "text/plain"}, ['404 Not Found']] }
|
16
|
-
```
|
17
16
|
How to
|
18
17
|
-----
|
19
18
|
|
@@ -28,20 +27,20 @@ When user access directory, Rack::CGI will use index script instand of.
|
|
28
27
|
If you not special index, Rack::CGI will not have a default value, and it's not works.
|
29
28
|
|
30
29
|
You can special index as follow:
|
31
|
-
```ruby
|
32
|
-
use Rack::CGI, index: 'index.php'
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
use Rack::CGI, index: 'index.php'
|
32
|
+
|
33
|
+
# or special multiple, Rack::CGI will try each by order
|
34
|
+
use Rack::CGI, index: ['index.php', 'index.cgi']
|
35
|
+
|
37
36
|
### Rules
|
38
37
|
|
39
38
|
When Rack::CGI found a script file in disk, it will try to find a rule to deal it.
|
40
39
|
|
41
40
|
You can special multiple rules, in follow format:
|
42
|
-
|
43
|
-
use Rack::CGI, match1 => deal1, match2 => deal2, match3 => deal3 ...
|
44
|
-
|
41
|
+
|
42
|
+
use Rack::CGI, match1 => deal1, match2 => deal2, match3 => deal3 ...
|
43
|
+
|
45
44
|
`match` can be Rack::CGI::Executable or Regexp.
|
46
45
|
Rack::CGI::Executable match all script that is executable.
|
47
46
|
Regexp will try to match script full path.
|
@@ -61,41 +60,41 @@ All relative resource will cannot accessed. In this case, we have to redirect 'h
|
|
61
60
|
'http://wps-community.org/forum/' to avoid this problem.
|
62
61
|
|
63
62
|
You can use following code to open this feature.
|
64
|
-
|
65
|
-
use Rack::CGI, ..., dir_redirect: true, ...
|
66
|
-
|
63
|
+
|
64
|
+
use Rack::CGI, ..., dir_redirect: true, ...
|
65
|
+
|
67
66
|
### Use Rack::CGI in Rails project
|
68
67
|
|
69
68
|
Originally I intended to write a project named rails-cgi.
|
70
69
|
But it's so trouble, and run Rack app in rails is not very complex.
|
71
70
|
So I give up rails-cgi.
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
$ rails g controller cgi
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# You can changed arguments as you want
|
80
|
-
CGI = Rack::Builder.new do
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
# add an action to controller
|
89
|
-
def cgi
|
90
|
-
|
91
|
-
end
|
92
|
-
# of course, you can add decoration code here, such as call rails layout
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
# add follow to config/routes.rb
|
97
|
-
get '/cgi-bin/*path' => 'cgi#cgi'
|
98
|
-
|
72
|
+
Create a cgi controller
|
73
|
+
|
74
|
+
$ rails g controller cgi
|
75
|
+
|
76
|
+
Create a Rack Application in CgiController
|
77
|
+
|
78
|
+
# You can changed arguments as you want
|
79
|
+
CGI = Rack::Builder.new do
|
80
|
+
use Rack::CGI, cgi_path: 'cgi', index: ['index.cgi', 'index.php'], Rack::CGI::Executable => '', /\.php$/ => '/usr/bin/php-cgi'
|
81
|
+
use Rack::Static, urls: ['/'], root: 'cgi'
|
82
|
+
run proc{ |env| raise ActionController::RoutingError, env['PATH_INFO'] + " not found!" }
|
83
|
+
end
|
84
|
+
|
85
|
+
Call Rack App in rails controller
|
86
|
+
|
87
|
+
# add an action to controller
|
88
|
+
def cgi
|
89
|
+
[self.status, self.response.headers, self.response_body] = CGI.call env
|
90
|
+
end
|
91
|
+
# of course, you can add decoration code here, such as call rails layout
|
92
|
+
|
93
|
+
Add route
|
94
|
+
|
95
|
+
# add follow to config/routes.rb
|
96
|
+
get '/cgi-bin/*path' => 'cgi#cgi'
|
97
|
+
|
99
98
|
TODO
|
100
99
|
----
|
101
100
|
|
data/lib/rack/cgi/version.rb
CHANGED