rack-jsonp-middleware 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +23 -20
  2. data/lib/rack/jsonp.rb +4 -1
  3. metadata +5 -5
data/README.md CHANGED
@@ -10,35 +10,38 @@ The main difference with the rest of them is that this one will add JSONP suppor
10
10
 
11
11
  Since 'callback' is a really generic parameter name if someone wants to get a JSONP response they must request it explicitly.
12
12
 
13
- ## Examples
13
+ Btw, don't forget to give a try to [J50Nπ](https://github.com/robertodecurnex/J50Npi) (a pure JS JSONP helper), they make a lovely couple together :P
14
14
 
15
- Given that ...
16
- http://domain.com/action.json
15
+ ## Authors
17
16
 
18
- Returns something like ...
19
- {"key":"value"}
17
+ Roberto Decurnex (nex.development@gmail.com)
20
18
 
21
- With Content-Type ...
22
- application/json
19
+ ## Install
23
20
 
24
- Then ...
25
- http://domain.com/action.jsonp?callback=success
21
+ If you are using Bundler you can easily add the following line to your Gemfile:
22
+ gem 'rack-jsonp-middleware'
26
23
 
27
- Will return ...
28
- success({"key":"value"})
24
+ Or you can just install it as a ruby gem by running:
25
+ $ gem install rack-jsonp-middleware
29
26
 
30
- With Content-Type ...
31
- application/javascript
27
+ ## Download
32
28
 
33
- But ...
34
- http://domain.com/action.json?callback=sucess
29
+ You can also clone the project with Git by running:
30
+ $ git clone git://github.com/robertodecurnex/rack-jsonp-middleware
35
31
 
36
- Will still returns ...
37
- {"key":"value"}
32
+ ## Examples
38
33
 
39
- With Content-Type ...
34
+ Given that http://domain.com/action.json returns the following:
35
+ {"key":"value"}
36
+ With the following Content-Type:
40
37
  application/json
41
38
 
42
- ## Notes
39
+ Then http://domain.com/action.jsonp?callback=J50Npi.success will return the following:
40
+ J50Npi.success({"key":"value"})
41
+ With the following Content-Type:
42
+ aplication/javascript
43
43
 
44
- [To be improved] Calling "something.jsonp" without a "callback" will return an empty 400 response
44
+ But http://domain.com/action.json?callback=J50Npi.sucess will still returns the following:
45
+ {"key":"value"}
46
+ With the following Content-Type:
47
+ application/json
data/lib/rack/jsonp.rb CHANGED
@@ -13,7 +13,10 @@ module Rack
13
13
 
14
14
  return [400,{},[]] if requesting_jsonp && !callback
15
15
 
16
- env['PATH_INFO'].sub!(/\.jsonp/i, '.json') if requesting_jsonp
16
+ if requesting_jsonp
17
+ env['PATH_INFO'].sub!(/\.jsonp/i, '.json')
18
+ env['REQUEST_URI'] = env['PATH_INFO']
19
+ end
17
20
 
18
21
  status, headers, body = @app.call(env)
19
22
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jsonp-middleware
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Roberto Decurnex
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-28 00:00:00 -03:00
18
+ date: 2010-12-29 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -92,6 +92,6 @@ rubyforge_project:
92
92
  rubygems_version: 1.3.7
93
93
  signing_key:
94
94
  specification_version: 3
95
- summary: rack-jsonp-middleware-0.0.1
95
+ summary: rack-jsonp-middleware-0.0.3
96
96
  test_files: []
97
97