raindeer 1.0.11 → 1.0.12
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/router/events/query.rb +33 -0
- data/lib/router/events/route_event.rb +2 -0
- data/lib/router/events/wildcard_event.rb +2 -0
- data/lib/router/router.rb +1 -1
- data/lib/router/trie.rb +2 -2
- data/lib/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77e92b2be47edb924c90e7f739604137c136dbf5e49cd4ac4c7429b7d816ec45
|
|
4
|
+
data.tar.gz: cf2a15661f4a4a4ae49e54e2e402a3aa9980ae31b5b0b9e1315be3e60149bfcd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43368b2577dd4730f1a844e96c7b28fdd530a337dadba4117385e46206ceac18514c8c212308c708c57d122bccbc879b62dbccb49277e8355c7ba51d00389ae1
|
|
7
|
+
data.tar.gz: f762f71c3d8fad84ba62abfde4cbc0785ff38bec518911eaf9f4b16d1797176671e08e1d0c1ae5812c4e81862b2305ab8a1006fa53745632b5c30a47602ccd2b
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'lowevent'
|
|
4
|
+
require 'uri'
|
|
5
|
+
|
|
6
|
+
module Rain
|
|
7
|
+
module Events
|
|
8
|
+
# A request's query string, like "q=rye" in "/search?q=rye", as a hash with symbol keys, for the events made from it.
|
|
9
|
+
module Query
|
|
10
|
+
class << self
|
|
11
|
+
# A request's path without its query string, which routes match on.
|
|
12
|
+
def path(request)
|
|
13
|
+
request.path.split('?', 2).first
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def parse(request)
|
|
17
|
+
string = request&.path.to_s.split('?', 2)[1]
|
|
18
|
+
return {} unless string
|
|
19
|
+
|
|
20
|
+
URI.decode_www_form(string).to_h.transform_keys(&:to_sym)
|
|
21
|
+
rescue ArgumentError
|
|
22
|
+
{}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def query
|
|
27
|
+
Query.parse(request)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Low::Events::RenderEvent.include(Query)
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/router/router.rb
CHANGED
|
@@ -81,7 +81,7 @@ module Rain
|
|
|
81
81
|
return response_event if response_event
|
|
82
82
|
|
|
83
83
|
if @routes['/*']
|
|
84
|
-
route = Route.new(path:
|
|
84
|
+
route = Route.new(path: Events::Query.path(request), verbs: @routes['/*'].verbs)
|
|
85
85
|
wildcard_event = Events::WildcardEvent.take(key: '/*', action: :render, route:, request:)
|
|
86
86
|
return wildcard_event if wildcard_event
|
|
87
87
|
end
|
data/lib/router/trie.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Rain
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def match(request:, current_node: @root_node, current_index: 0, params: {})
|
|
44
|
-
path =
|
|
44
|
+
path = Events::Query.path(request)
|
|
45
45
|
|
|
46
46
|
return [] if (key = path[current_index]).nil?
|
|
47
47
|
|
|
@@ -71,7 +71,7 @@ module Rain
|
|
|
71
71
|
|
|
72
72
|
# Mid nodes side_effect, end nodes render.
|
|
73
73
|
def route_event(next_index:, params:, request:, route:)
|
|
74
|
-
action =
|
|
74
|
+
action = Events::Query.path(request)[next_index].nil? ? :render : :side_effect
|
|
75
75
|
action = :receive if action == :render && request.body
|
|
76
76
|
|
|
77
77
|
actions = [action]
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raindeer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
@@ -317,6 +317,7 @@ files:
|
|
|
317
317
|
- lib/raindeer/integrations.rb
|
|
318
318
|
- lib/raindeer/raindeer.rb
|
|
319
319
|
- lib/router/events/cookies.rb
|
|
320
|
+
- lib/router/events/query.rb
|
|
320
321
|
- lib/router/events/receive_event.rb
|
|
321
322
|
- lib/router/events/route_event.rb
|
|
322
323
|
- lib/router/events/wildcard_event.rb
|