hobby-rpc 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hobby/rpc.rb +1 -35
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 448a25904b66f7dcc5aa8dcdd8cd9f9c93a49b2b92cc1f6e0b10876e3ff226f0
4
- data.tar.gz: c547bfeac7df6e8b9385e0fa22935c0e19363e09e2c2716da93cbd9683d13cd8
3
+ metadata.gz: 2d9a99da934ca9e20d217853f23e3fdeb8c4d164d55b7f12026baaf18f4806db
4
+ data.tar.gz: bd015a31a17d7c906b16b878c9550f33d2f531e17a73d3c1995c7f10192f4705
5
5
  SHA512:
6
- metadata.gz: c6f5a67aa5da6f11076c89f612c75632cd5545d264e6671f84cc2f2f6851c27d62e8d5b1431d07e0ad070bc0ca42969ea2a464deabeb0f78cc457d74415a019a
7
- data.tar.gz: e39d939760b011b2fce2069abb3c0e712dd3186b1fcbe5ce057633ecb40fcb6d378162dbc34c18647015e77970908909bbaa4f342693eb330d14f13bdae425e4
6
+ metadata.gz: 30d05b49c19b67c2b1418ebd9974d2e292947c54de17d2118d870d8cb9ad55cb81691ca2e5772f7c198d26ae2c4dc0057f32b1d5e81a4d448e7f86d0d6955e9d
7
+ data.tar.gz: 41e57a790ee5f0c75c8539257aef2b6ccee9d6fb04e60b15e5d3001528ac2580da708ce11ec95bdcfabe1f107837c146f1a46afbfa6876735c1c3d90b38f31b0
data/lib/hobby/rpc.rb CHANGED
@@ -1,40 +1,5 @@
1
1
  module Hobby
2
2
  class RPC
3
- class CORS
4
- def initialize app, origins: nil
5
- @app = app
6
- @origins = origins
7
- end
8
-
9
- def call env
10
- origin = '*'
11
-
12
- if @origins
13
- if @origins.include? env['HTTP_ORIGIN']
14
- origin = env['HTTP_ORIGIN']
15
- else
16
- return [400, {}, '400']
17
- end
18
- end
19
-
20
- case env['REQUEST_METHOD']
21
- when 'OPTIONS'
22
- response = Rack::Response.new
23
-
24
- response.add_header 'Access-Control-Allow-Origin', origin
25
- response.add_header 'Access-Control-Allow-Methods', 'POST, OPTIONS'
26
- response.add_header 'Access-Control-Allow-Headers', 'Authorization, Content-Type'
27
- response.add_header 'Access-Control-Max-Age', '86400'
28
-
29
- response.to_a
30
- else
31
- status, headers, body = @app.call env
32
- headers['Access-Control-Allow-Origin'] = '*'
33
- [status, headers, body]
34
- end
35
- end
36
- end
37
-
38
3
  module User
39
4
  def self.roles
40
5
  @roles ||= []
@@ -60,6 +25,7 @@ module Hobby
60
25
  require 'hobby'
61
26
  require 'hobby/auth'
62
27
  require 'hobby/json/keys'
28
+ require 'hobby/cors'
63
29
 
64
30
  include Hobby
65
31
  include Auth[User]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobby-rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoly Chernov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-26 00:00:00.000000000 Z
11
+ date: 2021-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hobby
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: hobby-cors
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.0
55
69
  description: A simple RPC system for callable Ruby constants. It allows to expose
56
70
  them over HTTP safely, only to authorized users.
57
71
  email: chertoly@gmail.com