rack-redirector 0.1.0 → 0.1.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 +54 -0
- data/rack-redirector.gemspec +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: 40adfc52fa851bb0fe93460b622d8907bef8a861
|
4
|
+
data.tar.gz: 666498846b11f5f7a137a085cb9a292860760799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa1ec283e8dd18698833ff44e96d23a21461e44faaaf6d85e65f75cad760ea6b4a91eac187652ff15603f538aed06542c9418509b252e448785548ade28265b3
|
7
|
+
data.tar.gz: eef820d4563236168a2dcdf4e396488c6edd6d36d14a1dd59c979a31a7fb998fbdf9b2738720cebb5e33ffd4d377e2fb1639225ad219a0b9c5139e556ded5ee3
|
data/README.md
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
##What's this
|
2
|
+
This is a simple redirector suited for Rack simple_router.
|
3
|
+
|
4
|
+
While <code>Rack::Recursive</code> requests another page internally, <code>Rack::Redirector</code> redirect to another page with 302 status code.
|
5
|
+
|
6
|
+
##Usage
|
7
|
+
|
8
|
+
####with simple_router
|
9
|
+
|
10
|
+
This is a simple sample that may not work but you will make sense of what can do with <code>Rack::Redirector</code>.
|
11
|
+
|
12
|
+
#config.ru
|
13
|
+
requrie 'rack/redirector'
|
14
|
+
require 'simple_router'
|
15
|
+
|
16
|
+
class MyApp
|
17
|
+
|
18
|
+
include SimpleRouter::DSL
|
19
|
+
|
20
|
+
get '/' do
|
21
|
+
#do something..
|
22
|
+
end
|
23
|
+
|
24
|
+
get '/home' do
|
25
|
+
authenticate
|
26
|
+
#do something..
|
27
|
+
end
|
28
|
+
|
29
|
+
get '/input' do
|
30
|
+
authenticate
|
31
|
+
#show form and post to /create action
|
32
|
+
end
|
33
|
+
|
34
|
+
post '/create' do
|
35
|
+
authenticate
|
36
|
+
unless request.params.empty?
|
37
|
+
#create record
|
38
|
+
redirect '/home'
|
39
|
+
else
|
40
|
+
redirect '/input?mode=back'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class << self
|
45
|
+
def redirect(location)
|
46
|
+
raise RedirectRequest.new(location)
|
47
|
+
end
|
48
|
+
|
49
|
+
def authenticate
|
50
|
+
redirect('/') unless current_user
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/rack-redirector.gemspec
CHANGED