flame 3.5.2 → 3.6.0
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/flame/dispatcher.rb +10 -5
- data/lib/flame/response.rb +0 -6
- data/lib/flame/route.rb +1 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcf30b3c7d0ec4bc8ad73a500492c9d3dcf8c72b
|
4
|
+
data.tar.gz: 4a983a6a28dfadd477337400752190d8a8cd54f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05fa7acabaa2b16f9cde14dc5de48fb4869bd3424dceece06c8068d2cc5ea5afa683c9b39fcd15319f1ebf94dc5af53679eef1c215aa7090cfd9b811829e5b79
|
7
|
+
data.tar.gz: 11c78bdbba3080266fb0486b42ebd9cfcbdfb02f7f90fcb88b2acf7a9d37e784655dad9954105f30b2d02aeb00500b5a5074a404fdd0381f553024696e94e17a
|
data/lib/flame/dispatcher.rb
CHANGED
@@ -28,6 +28,7 @@ module Flame
|
|
28
28
|
try_static(File.join(__dir__, '..', '..', 'public')) ||
|
29
29
|
try_error(404)
|
30
30
|
end
|
31
|
+
response.write body
|
31
32
|
response.finish
|
32
33
|
end
|
33
34
|
|
@@ -37,6 +38,10 @@ module Flame
|
|
37
38
|
value ? response.status = value : response.status
|
38
39
|
end
|
39
40
|
|
41
|
+
def body(value = nil)
|
42
|
+
value ? @body = value : @body
|
43
|
+
end
|
44
|
+
|
40
45
|
def params
|
41
46
|
@params ||= request.params.merge(request.params.keys_to_sym)
|
42
47
|
end
|
@@ -60,14 +65,14 @@ module Flame
|
|
60
65
|
path.empty? ? '/' : path
|
61
66
|
end
|
62
67
|
|
63
|
-
def halt(new_status = nil,
|
68
|
+
def halt(new_status = nil, new_body = nil, new_headers = {})
|
64
69
|
case new_status
|
65
|
-
when String then
|
70
|
+
when String then new_body = new_status
|
66
71
|
when Integer then status new_status
|
67
72
|
end
|
68
73
|
# new_status.is_a?(String) ? () : (status new_status)
|
69
|
-
|
70
|
-
|
74
|
+
new_body = default_body if new_body.nil? && body.empty?
|
75
|
+
body new_body if new_body
|
71
76
|
response.headers.merge!(new_headers)
|
72
77
|
throw :halt
|
73
78
|
end
|
@@ -101,7 +106,7 @@ module Flame
|
|
101
106
|
|
102
107
|
def execute_route(route)
|
103
108
|
exec_route = route.executable
|
104
|
-
|
109
|
+
exec_route.run!(self)
|
105
110
|
rescue => exception
|
106
111
|
dump_error(exception)
|
107
112
|
# status 500
|
data/lib/flame/response.rb
CHANGED
data/lib/flame/route.rb
CHANGED
@@ -104,9 +104,8 @@ module Flame
|
|
104
104
|
def run!(dispatcher)
|
105
105
|
@ctrl = @route[:controller].new(dispatcher)
|
106
106
|
execute_hooks(:before)
|
107
|
-
|
107
|
+
dispatcher.body @ctrl.send(@route[:action], *arranged_params)
|
108
108
|
execute_hooks(:after)
|
109
|
-
result
|
110
109
|
end
|
111
110
|
|
112
111
|
def execute_errors(status = 500)
|