faastruby 0.5.17 → 0.5.18

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: be62481891e7988206be9866782916c9bbd5213c8870645d86e4d598bc1246e6
4
- data.tar.gz: 27229e25d96cfd1710c5056babb467613972a18ade05e20ce697c2e265f5b098
3
+ metadata.gz: 5c5a4bcb83a358f5100f329a36f5cbe052a6a9e3eb085aed3fe04bdbcd5f62da
4
+ data.tar.gz: ac614dec04fb647cecee6abf8b5846c1097323d35ad5ba98b424149dabec1e5a
5
5
  SHA512:
6
- metadata.gz: 78e5ce7c09846351734aed179cc7aa3c387f95c7fdc6a653be1af8d1c4edb0322539e2d0be969bd784901bf914ce438296943510b8113ccf148cd1cfd48470c9
7
- data.tar.gz: 0a43bb0ede6a7dfe9071e9dfac1d47ca8753f972acc524c6e3184c9d3cd065d6f8b66a7c80702bf8d966aa93e8ff4cdcd2f651e43e9fd4a0049c86f4a08eca17
6
+ metadata.gz: 734eb6a83509dc4b2ddcdee49846d360d39ea36499424b98a4ba538130de7528153e4c680cba7754ddd9a3527b2440f93fb085710b301a4402e01678fc921229
7
+ data.tar.gz: 89435a82075fd0806b2f2434177e598ce1910f5fe0a57ff3a873868cc3157f669ec9b082cfa7260c6fd8c2d75e58dd1acce49da0301b12fffa70e44c2649bb5d
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.18 - Mar 19 2019
4
+ - Reverted changes from 0.5.17
5
+ - Refactored headers parsing
6
+ - Bump `faastruby-rpc` version
7
+ - Force RPC calls to use event.body instead of extra arguments
8
+ - Added `favicon.ico` to the public template to stop annoying catch-all invocations on log
9
+ - Match platform behaviour when render text is used on an object
10
+
3
11
  ## 0.5.17 - Mar 19 2019
4
12
  - Refactored headers parsing
5
13
  - Change Oj load behaviour to use hash with symbol keys when loading rpc_args
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faastruby (0.5.17)
4
+ faastruby (0.5.16)
5
5
  colorize (~> 0.8)
6
- faastruby-rpc (~> 0.2.6)
6
+ faastruby-rpc (~> 0.2.5)
7
7
  listen (~> 3.1)
8
8
  oj (~> 3.6)
9
9
  puma (~> 3.12)
@@ -30,7 +30,7 @@ GEM
30
30
  unf (>= 0.0.5, < 1.0.0)
31
31
  equatable (0.5.0)
32
32
  erubis (2.7.0)
33
- faastruby-rpc (0.2.6)
33
+ faastruby-rpc (0.2.5)
34
34
  oj (~> 3.6)
35
35
  ffi (1.10.0)
36
36
  hashdiff (0.3.7)
@@ -6,7 +6,6 @@ require 'sinatra/multi_route'
6
6
  require 'securerandom'
7
7
  require 'rouge'
8
8
  require 'colorize'
9
-
10
9
  module FaaStRuby
11
10
  class Server < Sinatra::Base
12
11
  include FaaStRuby::Logger::Requests
@@ -25,21 +24,24 @@ module FaaStRuby
25
24
  splat = params['splat'][0]
26
25
  function_name = resolve_function_name(splat)
27
26
  request_headers = parse_headers(env)
28
- if request_headers.has_key?('Faastruby-Rpc')
29
- body = nil
30
- rpc_args = parse_body(request.body.read, request_headers['Content-Type'], request.request_method, true) || []
31
27
 
32
- else
33
- body = parse_body(request.body.read, request_headers['Content-Type'], request.request_method)
34
- rpc_args = []
35
- end
28
+ # if headers.has_key?("Faastruby-Rpc")
29
+ # body = nil
30
+ # rpc_args = parse_body(request.body.read, headers['Content-Type'], request.request_method) || []
31
+ # else
32
+ # body = parse_body(request.body.read, headers['Content-Type'], request.request_method)
33
+ # rpc_args = []
34
+ # end
35
+
36
+ body = parse_body(request.body.read, request_headers['Content-Type'], request.request_method)
37
+ rpc_args = []
36
38
  request_headers['X-Request-Id'] = request_uuid
37
39
  request_headers['Request-Method'] = request.request_method
38
40
  original_request_id = request_headers['X-Original-Request-Id']
39
41
  query_params = parse_query(request.query_string)
40
42
  context = Oj.dump(FaaStRuby::ProjectConfig.secrets_for_function(function_name))
41
43
  event = FaaStRuby::Event.new(body: body, query_params: query_params, headers: request_headers, context: context)
42
- log_request_message(function_name, request, request_uuid, query_params, body || rpc_args, context, request_headers)
44
+ log_request_message(function_name, request, request_uuid, query_params, body, context, request_headers)
43
45
  time, response = FaaStRuby::Runner.new(function_name).call(event, rpc_args)
44
46
  status response.status
45
47
  headers set_response_headers(response, request_uuid, original_request_id, time)
@@ -49,7 +51,7 @@ module FaaStRuby
49
51
  end
50
52
 
51
53
  def log_request_message(function_name, request, request_uuid, query_params, body, context, request_headers)
52
- puts "[#{function_name}] <- [REQUEST: #{request.request_method} \"#{request.fullpath}\"] request_id=\"#{request_uuid}\" body=\"#{body}\" query_params=#{query_params} headers=#{request_headers}"
54
+ puts "[#{function_name}] <- [REQUEST: #{request.request_method} \"#{request.fullpath}\"] request_id=\"#{request_uuid}\" body=#{body.inspect} query_params=#{query_params} headers=#{request_headers}"
53
55
  end
54
56
 
55
57
  def log_response_message(function_name, time, request_uuid, response, print_body)
@@ -65,7 +67,7 @@ module FaaStRuby
65
67
 
66
68
  def parse_response(response)
67
69
  return [Base64.urlsafe_decode64(response.body), "Base64(#{response.body})"] if response.binary?
68
- return [response.body, "#{response.body}"]
70
+ return [response.body, response.body]
69
71
  end
70
72
 
71
73
  def resolve_function_name(splat)
@@ -82,14 +84,10 @@ module FaaStRuby
82
84
  File.file?("#{FaaStRuby::ProjectConfig.functions_dir}/#{name}/faastruby.yml")
83
85
  end
84
86
 
85
- def parse_body(body, content_type, method, rpc=false)
87
+ def parse_body(body, content_type, method)
86
88
  return nil if method == 'GET'
87
89
  return {} if body.nil? && method != 'GET'
88
- if rpc
89
- return Oj.load(body, symbol_keys: true) if content_type == 'application/json'
90
- else
91
- return Oj.load(body) if content_type == 'application/json'
92
- end
90
+ # return Oj.load(body) if content_type == 'application/json'
93
91
  return body
94
92
  end
95
93
 
@@ -48,7 +48,11 @@ module FaaStRuby
48
48
  end
49
49
  attr_accessor :body, :status, :headers, :binary
50
50
  def initialize(body:, status: 200, headers: {}, binary: false)
51
- @body = body
51
+ if body.is_a?(String) || body.nil?
52
+ @body = body
53
+ else
54
+ @body = body.inspect
55
+ end
52
56
  @status = status
53
57
  @headers = headers
54
58
  @binary = binary
@@ -40,7 +40,7 @@ module FaaStRuby
40
40
  resp_body = json.is_a?(String) ? json : Oj.dump(json)
41
41
  when html, inline
42
42
  headers["Content-Type"] ||= "text/html"
43
- resp_body = html
43
+ resp_body = html || inline
44
44
  when text
45
45
  headers["Content-Type"] ||= "text/plain"
46
46
  resp_body = text
@@ -1,3 +1,3 @@
1
1
  module FaaStRuby
2
- VERSION = '0.5.17'
2
+ VERSION = '0.5.18'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faastruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.17
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Arruda