blix-rest 0.11.1 → 0.11.2
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 +1 -0
- data/lib/blix/rest/controller.rb +15 -4
- data/lib/blix/rest/request_mapper.rb +0 -0
- data/lib/blix/rest/server.rb +9 -12
- data/lib/blix/rest/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 803e59de73313dfd8a4d1e78f4c3e597ef91f94aa69a8afd126e4dfe77d25305
|
4
|
+
data.tar.gz: cd860e9b57fe907b8289178727db163cdad13bac474b6b4bdfe3de76b0a824a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0554d9118f19d2bd60dbb740fdb41a2f7d4c38597d44f10effc055355098318818b117d9284947348fd71f1551eaadc3b941dae8a1e507d5aa39ea3ee89d0bf1
|
7
|
+
data.tar.gz: 7dfdfdf748c7ad96eb485863c741c2098df460fa4bfc7825dddab8fa05a3bedac83d7ecffe387fc604ff9fa4b09ca56e9f44cc45a592d641a58ce9a2a8591991
|
data/README.md
CHANGED
@@ -629,6 +629,7 @@ Here's a comprehensive list of helper methods available in Blix::Rest controller
|
|
629
629
|
- `render_erb`: Render an ERB template
|
630
630
|
- `req`: The Rack request object
|
631
631
|
- `request_ip`: The IP address of the request
|
632
|
+
- `route_options`: The options that were passed in the route definition.
|
632
633
|
- `send_data`: Send raw data with various options
|
633
634
|
- `send_error`: Send an error response
|
634
635
|
- `server_cache`: Get the server cache object
|
data/lib/blix/rest/controller.rb
CHANGED
@@ -29,7 +29,8 @@ module Blix::Rest
|
|
29
29
|
:format,
|
30
30
|
:response,
|
31
31
|
:method,
|
32
|
-
:server
|
32
|
+
:server,
|
33
|
+
:response_options # can be set during a call.
|
33
34
|
)
|
34
35
|
|
35
36
|
class Controller
|
@@ -76,11 +77,16 @@ module Blix::Rest
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def body
|
79
|
-
@_body ||=
|
80
|
-
|
80
|
+
@_body ||= begin
|
81
|
+
if env['rack.input']
|
82
|
+
env['rack.input'].read
|
83
|
+
else
|
84
|
+
''
|
85
|
+
end
|
86
|
+
end
|
81
87
|
end
|
82
88
|
|
83
|
-
#
|
89
|
+
# override the path method to return the internal path.
|
84
90
|
def path
|
85
91
|
p = CGI.unescape(req.path)
|
86
92
|
p = '/' + p if p[0, 1] != '/' # ensure a leading slash on path
|
@@ -298,6 +304,11 @@ module Blix::Rest
|
|
298
304
|
@_response.status = value.to_i
|
299
305
|
end
|
300
306
|
|
307
|
+
def set_options(value)
|
308
|
+
@_context.response_options ||= {}
|
309
|
+
@_context.response_options.merge!(value)
|
310
|
+
end
|
311
|
+
|
301
312
|
def add_headers(headers)
|
302
313
|
@_response.headers.merge!(headers.map{|k,v| [k.to_s.downcase,v]}.to_h)
|
303
314
|
end
|
File without changes
|
data/lib/blix/rest/server.rb
CHANGED
@@ -165,15 +165,12 @@ module Blix::Rest
|
|
165
165
|
blk, path_params, options = match_all if match_all && match_all[0]
|
166
166
|
|
167
167
|
default_format = options && options[:default] && options[:default].to_sym
|
168
|
-
force_format
|
169
|
-
do_cache
|
170
|
-
clear_cache
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
format = query_format || path_params[:format] || get_format_new(env, options) || default_format || :json
|
175
|
-
|
176
|
-
parser = get_parser(force_format || format)
|
168
|
+
force_format = options && options[:force] && options[:force].to_sym
|
169
|
+
do_cache = options && options[:cache] && !Blix::Rest.cache_disabled
|
170
|
+
clear_cache = options && options[:cache_reset]
|
171
|
+
query_format = options && options[:query] && req.GET['format'] && req.GET['format'].to_sym
|
172
|
+
format = query_format || path_params[:format] || get_format_new(env, options) || default_format || :json
|
173
|
+
parser = get_parser(force_format || format)
|
177
174
|
|
178
175
|
unless parser
|
179
176
|
if blk
|
@@ -196,7 +193,8 @@ module Blix::Rest
|
|
196
193
|
begin
|
197
194
|
params = env['params']
|
198
195
|
context = Context.new(path_params, params, req, format, response, verb, self)
|
199
|
-
value
|
196
|
+
value = blk.call(context)
|
197
|
+
response_options = context.response_options || {}
|
200
198
|
rescue ServiceError => e
|
201
199
|
set_default_headers(parser, response)
|
202
200
|
response.set(e.status, parser.format_error(e.message), e.headers)
|
@@ -216,7 +214,6 @@ module Blix::Rest
|
|
216
214
|
logger << e.message
|
217
215
|
logger << e.backtrace.join("\n")
|
218
216
|
else # no error
|
219
|
-
response_options ||= {}
|
220
217
|
response.set_options(response_options)
|
221
218
|
if response_options[:raw]
|
222
219
|
response.content = value
|
@@ -233,7 +230,7 @@ module Blix::Rest
|
|
233
230
|
response.set(404, parser.format_error('Invalid Url'))
|
234
231
|
end
|
235
232
|
|
236
|
-
logger << "#{verb} #{path} total time=#{((Time.now - t1) * 1000).round(2)}ms"
|
233
|
+
logger << "#{verb} #{path} total time=#{((Time.now - t1) * 1000).round(2)}ms" if $VERBOSE
|
237
234
|
[response.status.to_i, response.headers, response.content]
|
238
235
|
end
|
239
236
|
|
data/lib/blix/rest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blix-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clive Andrews
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.2.3
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Framework for HTTP REST services
|