syro 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gems +1 -1
- data/CHANGELOG +4 -0
- data/README.md +29 -1
- data/lib/syro.rb +4 -0
- data/syro.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5bd169764accc1559a997f38c5a350e1b738f10
|
4
|
+
data.tar.gz: 6fc78b2e65bd001d3a88bbb216c5f9aa214ab889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a6cc7183e4c0b977769b34805e7d5dab8665384f986dae55605be896423db304420fb5309fc75b97b8594a131ea7a5536f9b3d21f642122dbab43dbd3ebbb9d
|
7
|
+
data.tar.gz: 73921b5292db07295b5ee25e90d364093cd6e2d60b4dc9a151bad63ab24e568337a8eddb78c3e87706f3b9bb2bddb64ba98eba98f6d9720274690df0464605c5
|
data/.gems
CHANGED
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,8 @@ app = Syro.new {
|
|
37
37
|
|
38
38
|
The block is evaluated in a sandbox where the following methods are
|
39
39
|
available: `env`, `req`, `res`, `inbox`, `call`, `run`, `halt`,
|
40
|
-
`match`, `on`, `root?`, `root`,`get`, `post`, `patch` and
|
40
|
+
`match`, `on`, `root?`, `root`,`get`, `put`, `post`, `patch` and
|
41
|
+
`delete`.
|
41
42
|
|
42
43
|
As a recommendation, user created variables should be instance
|
43
44
|
variables. That way they won't mix with the API methods defined in
|
@@ -80,6 +81,9 @@ executed only if the request is matched.
|
|
80
81
|
`get`: Receives a block and calls it only if `root?` and `req.get?` are
|
81
82
|
true.
|
82
83
|
|
84
|
+
`put`: Receives a block and calls it only if `root?` and `req.put?` are
|
85
|
+
true.
|
86
|
+
|
83
87
|
`post`: Receives a block and calls it only if `root?` and `req.post?`
|
84
88
|
are true.
|
85
89
|
|
@@ -146,6 +150,10 @@ app = Syro.new {
|
|
146
150
|
res.write "GET /users/42"
|
147
151
|
}
|
148
152
|
|
153
|
+
put {
|
154
|
+
res.write "PUT /users/42"
|
155
|
+
}
|
156
|
+
|
149
157
|
patch {
|
150
158
|
res.write "PATCH /users/42"
|
151
159
|
}
|
@@ -216,6 +224,26 @@ There are no rendering features built into this routing library. A
|
|
216
224
|
framework that uses this routing library can easily implement helpers
|
217
225
|
for rendering.
|
218
226
|
|
227
|
+
Middleware
|
228
|
+
----------
|
229
|
+
|
230
|
+
Syro doesn't support Rack middleware out of the box. If you need them,
|
231
|
+
just use `Rack::Builder`:
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
app = Rack::Builder.new do
|
235
|
+
|
236
|
+
use Rack::Session::Cookie, secret: "..."
|
237
|
+
|
238
|
+
run Syro.new {
|
239
|
+
get {
|
240
|
+
res.write("Hello, world")
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
end
|
245
|
+
```
|
246
|
+
|
219
247
|
Trivia
|
220
248
|
------
|
221
249
|
|
data/lib/syro.rb
CHANGED
@@ -125,11 +125,15 @@ class Syro
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def run(app, inbox = {})
|
128
|
+
path, script = env[Rack::PATH_INFO], env[Rack::SCRIPT_NAME]
|
129
|
+
|
128
130
|
env[Rack::PATH_INFO] = @syro_path.curr
|
129
131
|
env[Rack::SCRIPT_NAME] = @syro_path.prev
|
130
132
|
env[Syro::INBOX] = inbox
|
131
133
|
|
132
134
|
halt(app.call(env))
|
135
|
+
ensure
|
136
|
+
env[Rack::PATH_INFO], env[Rack::SCRIPT_NAME] = path, script
|
133
137
|
end
|
134
138
|
|
135
139
|
def halt(response)
|
data/syro.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: seg
|