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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f5bf0f69af1e2fbd2bfeb686b928133b716334f9c51c24b07083e040478f7a6
4
- data.tar.gz: 4caa54dd10af46e6d86a0e522c8a8f6a05081ccf6bd67df225b8c5c779ffcb63
3
+ metadata.gz: fd4c35292f230db30dd6f3336fe819b5ef97c4cf48c10d6d6a607e9211ae85ed
4
+ data.tar.gz: 5c6ac17162617bf2703ab60f4c7f507e96a793be402fe72bde97dea1621ed347
5
5
  SHA512:
6
- metadata.gz: d1ec8a4a2960116dd307c1a2080effec158ef61d8b41e02ebe9fca3cb73e4dd49e43291893eebc283367eb28b449bd815f1f86dc8704127da07f9d32a1fddf4b
7
- data.tar.gz: 600bf96bba50d750df67eace20d30c50b56d55de7e726e83da60cba1e44058ecf9c569366c943a4907e9c94fc3b921c12bdc7deb89a79fe2bd10b3bd77be2149
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
@@ -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
@@ -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)
@@ -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
@@ -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.8'
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']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wouter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Peterson