rack-http_router 0.0.2 → 0.0.31
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/lib/rack-http_router/action.rb +3 -2
- data/lib/rack-http_router/router.rb +4 -3
- data/lib/rack-http_router.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 161320de9187e5cbb240dc21f2e8e0022de852686cc5d462d60c8b80c2a58a21
|
4
|
+
data.tar.gz: 65afaba8af50fa630e7f20d647de6531302352fce8e9b4de8e3589514e9923f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1e97f0bf724b0c6e279db38ffc38eb3a51cd5b1c2e0ec321efe7ae6ef5b364f9f862a1803a5ca0290b98c84b32123b3c5c053fd05301c595ae504ccc2673b7
|
7
|
+
data.tar.gz: e3d0df2a1110d94026a3eac1a0a84bf6ab1002ef61a43ac8d8a38a7314cd1f8d9f6cf7faced23efd8d77d2b50f24ac2c0c1b017810a53849869e89738c2d50b2
|
@@ -9,10 +9,11 @@ module Rack
|
|
9
9
|
module Action
|
10
10
|
def self.included(base)
|
11
11
|
base.class_eval do
|
12
|
-
attr_reader :route if self != Rack::HttpRouter
|
12
|
+
attr_reader :route, :config if self != Rack::HttpRouter
|
13
13
|
|
14
|
-
def initialize(route)
|
14
|
+
def initialize(route, config)
|
15
15
|
@route = route
|
16
|
+
@config = config
|
16
17
|
end
|
17
18
|
|
18
19
|
def view_response(a_path, a_view_params = {}, status: 200)
|
@@ -9,9 +9,9 @@ module Rack
|
|
9
9
|
class UndefinedNamedRoute < StandardError; end
|
10
10
|
|
11
11
|
attr_writer :not_found
|
12
|
-
attr_reader :route
|
12
|
+
attr_reader :route, :config
|
13
13
|
|
14
|
-
def initialize
|
14
|
+
def initialize(config = {})
|
15
15
|
@routes = {}
|
16
16
|
%w[GET POST DELETE PUT TRACE OPTIONS PATCH].each do |method|
|
17
17
|
@routes[method] = { __instances: [] }
|
@@ -19,6 +19,7 @@ module Rack
|
|
19
19
|
@route = Hash.new do |_hash, key|
|
20
20
|
raise(UndefinedNamedRoute, "Undefined named route: '#{key}'")
|
21
21
|
end
|
22
|
+
@config = config
|
22
23
|
@scopes = []
|
23
24
|
@error = proc { |_req, e| raise e }
|
24
25
|
@not_found = proc { [404, {}, ['Not found']] }
|
@@ -37,7 +38,7 @@ module Rack
|
|
37
38
|
end
|
38
39
|
|
39
40
|
if route_instance.endpoint.include?(Rack::HttpRouter::Action)
|
40
|
-
return route_instance.endpoint.new(@route).call(request_builder.call(route_instance))
|
41
|
+
return route_instance.endpoint.new(@route, @config).call(request_builder.call(route_instance))
|
41
42
|
end
|
42
43
|
|
43
44
|
route_instance.endpoint.new.call(request_builder.call(route_instance))
|
data/lib/rack-http_router.rb
CHANGED
@@ -7,8 +7,9 @@ module Rack
|
|
7
7
|
class HttpRouter
|
8
8
|
include Action
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
|
10
|
+
def initialize(config = {})
|
11
|
+
p "oi"
|
12
|
+
@router = Router.new(config)
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(&block)
|
@@ -21,6 +22,10 @@ module Rack
|
|
21
22
|
@router.route
|
22
23
|
end
|
23
24
|
|
25
|
+
def config
|
26
|
+
@router.config
|
27
|
+
end
|
28
|
+
|
24
29
|
def scope(name, &block)
|
25
30
|
@router.append_scope(name)
|
26
31
|
instance_eval(&block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-http_router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique F. Teixeira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubi
|