wouter 0.0.8 → 0.0.9
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 -0
- data/lib/wouter.rb +5 -1
- data/lib/wouter/endpoint.rb +5 -4
- data/lib/wouter/wrapper.rb +3 -2
- data/wouter.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd4c35292f230db30dd6f3336fe819b5ef97c4cf48c10d6d6a607e9211ae85ed
|
4
|
+
data.tar.gz: 5c6ac17162617bf2703ab60f4c7f507e96a793be402fe72bde97dea1621ed347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2893cd88f2bc0ecd8d299ee03629ed6d2d57c6524ffeb6eb4b44985d085c70c30ae2551d61792469f291a5f7c377a61a7aa5641c24e5f915dd1879bfacae4108
|
7
|
+
data.tar.gz: f42f3985c80a5606f33726d66ced3c55aeb5f4a0378cea8f12d85047c849540191befa1e0ecfd5bb522166721708209f8137765681670b262e9a94c9a406a3cf
|
data/README.md
CHANGED
@@ -57,3 +57,7 @@ Instances of `Wouter::Endpoint` have access to a few helper methods.
|
|
57
57
|
* `headers` - convience method for getting and setting HTTP headers
|
58
58
|
* `status` - get or set HTTP status code
|
59
59
|
* `not_found` - generates a HTTP 404 Not Found `Rack::Response`
|
60
|
+
|
61
|
+
# Extensions
|
62
|
+
|
63
|
+
* [wouter-views](https://github.com/rawburt/wouter-views) - View template support for Wouter web framework
|
data/lib/wouter.rb
CHANGED
@@ -36,7 +36,7 @@ class Wouter
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def build
|
39
|
-
app.run(Wrapper.new(routes: routes))
|
39
|
+
app.run(Wrapper.new(routes: routes, config: config))
|
40
40
|
app.to_app
|
41
41
|
end
|
42
42
|
|
@@ -50,6 +50,10 @@ class Wouter
|
|
50
50
|
@routes ||= []
|
51
51
|
end
|
52
52
|
|
53
|
+
def config
|
54
|
+
@config ||= {}
|
55
|
+
end
|
56
|
+
|
53
57
|
def define_route(request_method, path, klass)
|
54
58
|
routes << Wouter::Route.new(request_method: request_method, path: path, klass: klass)
|
55
59
|
end
|
data/lib/wouter/endpoint.rb
CHANGED
@@ -7,15 +7,16 @@
|
|
7
7
|
class Wouter::Endpoint
|
8
8
|
class NotImplementedError < StandardError; end
|
9
9
|
|
10
|
-
attr_reader :req, :res
|
10
|
+
attr_reader :req, :res, :config
|
11
11
|
|
12
|
-
def initialize(req, res)
|
12
|
+
def initialize(req, res, config = {})
|
13
13
|
@req = req
|
14
14
|
@res = res
|
15
|
+
@config = config
|
15
16
|
end
|
16
17
|
|
17
|
-
def self.call(env)
|
18
|
-
endpoint = new(Rack::Request.new(env), Rack::Response.new)
|
18
|
+
def self.call(env, config = {})
|
19
|
+
endpoint = new(Rack::Request.new(env), Rack::Response.new, config)
|
19
20
|
response = endpoint.respond
|
20
21
|
|
21
22
|
return response.finish if response.is_a?(Rack::Response)
|
data/lib/wouter/wrapper.rb
CHANGED
@@ -5,8 +5,9 @@
|
|
5
5
|
# to the appropriate route class that was defined by the user.
|
6
6
|
#
|
7
7
|
class Wouter::Wrapper
|
8
|
-
def initialize(routes:)
|
8
|
+
def initialize(routes:, config: {})
|
9
9
|
@routes = routes
|
10
|
+
@config = config
|
10
11
|
end
|
11
12
|
|
12
13
|
def call(env)
|
@@ -17,7 +18,7 @@ class Wouter::Wrapper
|
|
17
18
|
route.params(request).each do |name, value|
|
18
19
|
request.update_param(name, value)
|
19
20
|
end
|
20
|
-
route.klass.call(request.env)
|
21
|
+
route.klass.call(request.env, @config)
|
21
22
|
else
|
22
23
|
Wouter::Util.not_found
|
23
24
|
end
|
data/wouter.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'wouter'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.9'
|
7
7
|
s.summary = 'Rack web framework.'
|
8
8
|
s.description = 'Wouter is a modular web framework built on top of Rack.'
|
9
9
|
s.authors = ['Robert Peterson']
|