gimmie 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/README.md +77 -0
  2. metadata +7 -6
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Gimmie Rack Library
2
+
3
+ This gem is Rack application to provide a reverse proxy for Gimmie REST API
4
+
5
+ ## Installation
6
+
7
+ gem install gimmie
8
+
9
+ If you are using `bundler`, add this into your `Gemfile`
10
+
11
+ gem "gimmie"
12
+
13
+ ### Configuration
14
+
15
+ Gimmie Proxy library prefers configuration to be set as environment variables
16
+
17
+ GIMMIE_OAUTH_KEY
18
+ GIMMIE_OAUTH_SECRET
19
+ GIMMIE_COOKIE_KEY
20
+ GIMMIE_URL_PREFIX
21
+
22
+ In this way, the `Gimmie::Proxy` object can be simply initialized as
23
+
24
+ Gimmie::Proxy.new
25
+
26
+ Alternatively, configuration can be set as constructor arguments, e.g.
27
+
28
+ Gimmie::Proxy.new({
29
+ cookie_key: '_gm_key',
30
+ oauth_key: 'onetwothree',
31
+ oauth_secret: 'fourfivesix',
32
+ url_prefix: 'https://api.gimmieworld.com',
33
+ })
34
+
35
+ ### Rack
36
+
37
+ Create a file `config.ru` with the following code
38
+
39
+ require 'gimmie'
40
+ run Gimmie::Proxy.new
41
+
42
+ Next, execute the command
43
+
44
+ rackup
45
+
46
+ This will run a web server on port 9292. You can test by sending a HTTP request, e.g.
47
+
48
+ curl -i 'http://localhost:9292/gimmieapi=/1/rewards.json'
49
+
50
+ If your `GIMMIE_URL_PREFIX` is `https://api.gimmieworld.com`, then an OAuth request will sent to `https://api.gimmieworld.com/1/rewards.json` and the response will be echoed back
51
+
52
+ ### Rails
53
+
54
+ To add Gimmie Proxy into your existing Rails application, simply provide a route in your `config/routes.rb` file, e.g.
55
+
56
+ match "/gimmie_proxy" => Gimmie::Proxy.new
57
+
58
+ You can test by sending a HTTP request, e.g.
59
+
60
+ curl -i 'http://localhost:3000/gimmie_proxy?gimmieapi=/1/rewards.json?x=y'
61
+
62
+ NOTE: the mount path can be anything, Gimmie Proxy does not care; it only looks for the `gimmieapi=` string and ignore everything that comes before.
63
+
64
+ If your `GIMMIE_URL_PREFIX` is `https://api.gimmieworld.com`, then an OAuth request will sent to `https://api.gimmieworld.com/1/rewards.json?x=y` and the response will be echoed back
65
+
66
+ ## What's this proxy for?
67
+
68
+ Talking to [Gimmie APIs](https://portal.gimmieworld.com/documentation/json) from the server-side should not be an issue for most developers since the technology stack consists of standards like `HTTP`, `OAuth` and `JSON`.
69
+
70
+ However, client apps that run on the browser would have problems securing their `OAuth` credentials. The solution is to run a reverse proxy on your own infrastructure and have the client apps talk (without OAuth) to the OAuth configured reverse proxy (which would relay the request to `api.gimmieworld.com` and echo the response back to the browser)
71
+
72
+ Meaning, a browser request to
73
+
74
+ * `http://www.yourserver.com/some/path?gimmieapi=/1/stores.json?hello=world` would be forwarded to
75
+ * `http://api.gimmieworld.com/1/stores.json?hello=world`
76
+
77
+ When referencing the [API documentation](https://portal.gimmieworld.com/documentation/json), simply replace the url prefix `http://api.gimmieworld.com` with your own reverse proxy url. Everything will still apply as-is.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimmie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-13 00:00:00.000000000 Z
12
+ date: 2013-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70209981500640 !ruby/object:Gem::Requirement
16
+ requirement: &70225282259800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.4.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70209981500640
24
+ version_requirements: *70225282259800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: oauth
27
- requirement: &70209981500060 !ruby/object:Gem::Requirement
27
+ requirement: &70225282259260 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,13 +32,14 @@ dependencies:
32
32
  version: 0.4.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70209981500060
35
+ version_requirements: *70225282259260
36
36
  description: Rack application to provide a reverse proxy for Gimmie REST API
37
37
  email: choonkeat@gmail.com
38
38
  executables: []
39
39
  extensions: []
40
40
  extra_rdoc_files: []
41
41
  files:
42
+ - README.md
42
43
  - lib/gimmie.rb
43
44
  - lib/gimmie/proxy.rb
44
45
  homepage: http://gimmieworld.com