moonrope 1.2.3 → 1.2.4

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
  SHA1:
3
- metadata.gz: 4ca7d3b849626bd7477fd623f803efef91abf3a8
4
- data.tar.gz: a448481684afb1dad860df02c8aac6f8419c9254
3
+ metadata.gz: 7a005ba55f00db5d481ac58a7160e591e993c39b
4
+ data.tar.gz: 0189df9139aa0bf21c6a991592632478a2dbd769
5
5
  SHA512:
6
- metadata.gz: e4eaaf33ce1636336e0d3f4ab4a600dba3d73e63e1e46c8b420c3f576675ce7349b869805f6de11a8392cb4cd992755671a038da03cf8a88a4a8bcdb0645387f
7
- data.tar.gz: d0f623ea767e7a2e5efdb52c8dd531ebf6e2a1170d42d1833443fb49d98034fa7a8d2f9a074759b3708e8750e4786a669b29bbe51123e9610e5262b462a1088b
6
+ metadata.gz: f6d0eb2be42d7b122abf4abc8bfbe7575523511bef0215c669f4455e44768273cc4744fddc5da475f521307e516e684e42ddab466b20014faa0d62bdd5a978ab
7
+ data.tar.gz: aa90abdd05744a1fd171a53f278d4b35bc5cdcbf647bfa343933538b7e2c4223617ad511a4bfbdcc5aa3aeb0ebc7a4a4da14be26f619b90317abb6e27a649557
@@ -33,15 +33,35 @@ module Moonrope
33
33
  #
34
34
  request = @base.request(env, $1)
35
35
 
36
+ #
37
+ # Set some global headers which are always returned
38
+ #
39
+ global_headers = {}
40
+ global_headers['Content-Type'] = 'text/plain'
41
+ global_headers['Access-Control-Allow-Origin'] = '*'
42
+ if env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']
43
+ global_headers['Access-Control-Allow-Headers'] = env['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']
44
+ end
45
+ global_headers['Access-Control-Allow-Methods'] = '*'
46
+
47
+ #
48
+ # Options always returns a 200
49
+ #
50
+ if env['REQUEST_METHOD'] == 'OPTIONS'
51
+ return [200, global_headers, ['OK']]
52
+ end
53
+
54
+ #
55
+ # Responses are now in JSON
56
+ #
57
+ global_headers['Content-Type'] = 'application/json'
58
+
36
59
  #
37
60
  # Check the request is valid
38
61
  #
39
62
  unless request.valid?
40
- return [400, {}, ["Invalid API Request. Must provide a version, controller & action as /api/v1/controller/action."]]
63
+ return [400, global_headers, [{:status => 'invalid-controller-or-action'}.to_json]]
41
64
  end
42
-
43
- global_headers = {}
44
- global_headers['Content-Type'] = 'application/json'
45
65
 
46
66
  #
47
67
  # Execute the request
@@ -1,3 +1,3 @@
1
1
  module Moonrope
2
- VERSION = '1.2.3'
2
+ VERSION = '1.2.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moonrope
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2014-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json