http-client-generator 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6dad1a9311f8ed3a1e2ed19c09ad0880374376faaf043f380465d9481ceca185
4
- data.tar.gz: a6ba9caa0b086a5523803da58f6df9706daf1fe72a091be24afcb6226b2c374d
3
+ metadata.gz: b11568b03959898b529b0c5c7fa35c95a3f0501553f84eeff49c088b92fb4c14
4
+ data.tar.gz: 2a287d40c99b2c217fa5e8679aba6e15179ab9cd0941212a3d2a137d65f2e73d
5
5
  SHA512:
6
- metadata.gz: 631a723643730d1339821b3b38458523123f9e30658ac81c4a6a6692f703fdc1c3488f50d36a2a12f2aea7d559284b9eeba9a2cb3db1fdeb0e061649d28f3052
7
- data.tar.gz: 4beff091ffaf387e71b0d1233f9a74eeb77ad1beb4f023d0ced6e2b69b506d2e641505a424c291ed0c655ecf1e9f0955e0befb0f1f4fb191f8618627985f7321
6
+ metadata.gz: 21e564cdb8cdfaca86807955440d06c14d9d80ebfd2322eb2d79b784f2ca111b6ef46c167e0d7e994b10ae562eb438cdb7d84155cd6dd7e39ac6366db45b80bd
7
+ data.tar.gz: 7575ecc971dc44da55858f14d39dd32fcc5cb78b7f6b9be54884737634a8e08274899ab81318b0746646c9fd1ed8f9b20f1001809c5fe8793a378023b4e2a2f2
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HttpClientGenerator
4
+ class Plugs
5
+ class SetBearerToken
6
+ Plugs.register :set_bearer_token, self
7
+
8
+ def initialize(from_arg:)
9
+ @from_arg = from_arg
10
+ end
11
+
12
+ def call(req)
13
+ token = req.rest_args[@from_arg]
14
+
15
+ req.headers[:authorization] = "Bearer #{token}"
16
+
17
+ req
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -15,9 +15,12 @@ module HttpClientGenerator
15
15
  arg = req.rest_args[@arg]
16
16
 
17
17
  req.headers[@header] =
18
- if @func
18
+ case @func&.arity
19
+ in 1
19
20
  @func.(arg)
20
- else
21
+ in 2
22
+ @func.(req, arg)
23
+ in nil
21
24
  arg
22
25
  end
23
26
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HttpClientGenerator
4
- VERSION = '0.1.20'
4
+ VERSION = '0.1.21'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-client-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Egorov
@@ -51,6 +51,7 @@ files:
51
51
  - lib/http_client_generator/plugs/camelize_body.rb
52
52
  - lib/http_client_generator/plugs/encode_json_response.rb
53
53
  - lib/http_client_generator/plugs/enforce_json_response.rb
54
+ - lib/http_client_generator/plugs/set_bearer_token.rb
54
55
  - lib/http_client_generator/plugs/set_header.rb
55
56
  - lib/http_client_generator/plugs/set_request_id.rb
56
57
  - lib/http_client_generator/plugs/underscore_response.rb