soar_sc-rack-router 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 +4 -4
- data/lib/soar_sc/rack/router/errors.rb +2 -0
- data/lib/soar_sc/rack/router/route.rb +9 -0
- data/lib/soar_sc/rack/router/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: e0d01611a439740ed9559a1a00c73a5641becc7b
|
4
|
+
data.tar.gz: 48a48a2e58137330af37778ee387b123e69e590b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a762f1d8ae8e5a11647b4285ad6021ff280ad9b9b3c7bbaa5bc458951c5948df0e442190d6186640e5d195ffa726a100362f31080a0b55c51052e6a41569912
|
7
|
+
data.tar.gz: d10e6b1d19b54fd6fc55d8afb71f01314376986e0e2bc75e75189140f11ba9dea5b0cd48050c50a06b6e20ee46939de829a47740cf941744ea12c366a7ac5537
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ Or install it yourself as:
|
|
34
34
|
|
35
35
|
The following are not examples of sensible ways to structure your router actions. They just demonstrate the SoarSc::Rack::Router API.
|
36
36
|
|
37
|
-
An example of a
|
37
|
+
An example of a multi-router stack:
|
38
38
|
|
39
39
|
```ruby
|
40
40
|
require 'soar_sc/rack/router'
|
@@ -51,7 +51,7 @@ stack = Rack::Builder.new do
|
|
51
51
|
post "/business", ->(env) { ... }
|
52
52
|
end
|
53
53
|
|
54
|
-
run ->(env) [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']]
|
54
|
+
run ->(env) { [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']] }
|
55
55
|
end
|
56
56
|
|
57
57
|
run stack
|
@@ -75,7 +75,7 @@ stack = Rack::Builder.new do
|
|
75
75
|
run ->(...)
|
76
76
|
end
|
77
77
|
|
78
|
-
run ->(env) [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']]
|
78
|
+
run ->(env) { [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']] }
|
79
79
|
end
|
80
80
|
end
|
81
81
|
```
|
@@ -94,7 +94,7 @@ stack = Rack::Builder.new do
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
run ->(env) [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']]
|
97
|
+
run ->(env) { [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']] }
|
98
98
|
end
|
99
99
|
|
100
100
|
run stack
|
@@ -6,6 +6,7 @@ module SoarSc
|
|
6
6
|
attr_reader :method, :path, :action
|
7
7
|
|
8
8
|
def initialize(method, path, action)
|
9
|
+
validate_path(path)
|
9
10
|
@method, @path, @action = method, path, action
|
10
11
|
end
|
11
12
|
|
@@ -43,6 +44,14 @@ module SoarSc
|
|
43
44
|
path.split('/')
|
44
45
|
end
|
45
46
|
|
47
|
+
def validate_path(path)
|
48
|
+
components(path).each do |c|
|
49
|
+
if c.start_with?(":") and c !~ /:[a-z_][a-z0-9_]*+/
|
50
|
+
raise InvalidParameterError, "Invalid parameter #{c} in path #{path}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
46
55
|
end
|
47
56
|
|
48
57
|
end
|