proxy_stack 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.0
@@ -1,4 +1,3 @@
1
- require 'couchrest'
2
1
  require 'net/http'
3
2
 
4
3
  class ProxyStack::Configuration
@@ -43,7 +43,7 @@ class ProxyStack
43
43
  def extract_http_headers
44
44
  out = {}
45
45
  request.env.keys.each do |key|
46
- if key. !~ /^(pancake|rack|content-length|transfer-encoding)/i
46
+ if key !~ /^(pancake|rack|content-length|transfer-encoding)/i
47
47
  out[key] = request.env[key]
48
48
  end
49
49
  end
@@ -53,9 +53,35 @@ class ProxyStack
53
53
 
54
54
  Pancake::MimeTypes.type_by_extension(:json).type_strings << "application/x-javascript"
55
55
 
56
+ def self.before_proxy(&block)
57
+ self::Controller.before_proxy << block
58
+ end
59
+
60
+ def self.after_proxy(&block)
61
+ self::Controller.after_proxy << block
62
+ end
63
+
64
+ class self::Controller
65
+ class_inheritable_reader :before_proxy, :after_proxy
66
+ @before_proxy = []
67
+ @after_proxy = []
68
+
69
+ private
70
+ def execute_blocks!(blks)
71
+ blks.each{|b| instance_eval(&b)}
72
+ end
73
+
74
+ def proxy_result
75
+ @proxy_result
76
+ end
77
+ end
78
+
56
79
  publish :provides => [:any]
57
- any "/(*proxy_path_segments)" do
58
- proxy_request!
80
+ any "{.*}" do
81
+ execute_blocks!(self.class.before_proxy)
82
+ @proxy_result = proxy_request!
83
+ execute_blocks!(self.class.after_proxy)
84
+ @proxy_result
59
85
  end
60
86
  end
61
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Neighman
@@ -40,9 +40,6 @@ files:
40
40
  - lib/proxy_stack.rb
41
41
  - lib/proxy_stack/config.ru
42
42
  - lib/proxy_stack/config/config.rb
43
- - lib/proxy_stack/config/environments/development.rb
44
- - lib/proxy_stack/config/environments/production.rb
45
- - lib/proxy_stack/config/environments/staging.rb
46
43
  - lib/proxy_stack/proxy_stack.rb
47
44
  - lib/proxy_stack/tasks/proxy_stack.rake
48
45
  - spec/proxy_stack_spec.rb
@@ -1,18 +0,0 @@
1
- Pancake.logger.info "Loading Development Environment"
2
-
3
- # Set the middleware lables to load
4
- Pancake.stack_labels = [:development]
5
-
6
- # Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
7
-
8
- class ProxyStack
9
- # include middleware for the development stack
10
- # stack(:middleware_name).use(MiddlewareClass)
11
- end
12
-
13
- # Add code to hooks. Default available hooks:
14
- # :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
15
-
16
- # ProxyStack.before_build_stack do
17
- # # stuff to do
18
- # end
@@ -1,19 +0,0 @@
1
- Pancake.logger.info "Loading Production Environment"
2
-
3
- # Set the middleware lables to load
4
- Pancake.stack_labels = [:production]
5
-
6
- Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
7
-
8
- class ProxyStack
9
- # include middleware for the development stack
10
- # stack(:middleware_name).use(MiddlewareClass)
11
- end
12
-
13
- # Add code to hooks. Default available hooks:
14
- # :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
15
-
16
- # ProxyStack.before_build_stack do
17
- # # stuff to do
18
- # end
19
-
@@ -1,20 +0,0 @@
1
- Pancake.logger.info "Loading Staging Environment"
2
-
3
- # Set the middleware lables to load
4
- Pancake.stack_labels = [:staging]
5
-
6
- Pancake.handle_errors!(true) # uncomment to have the stack handle any errors that occur
7
-
8
- class ProxyStack
9
- # include middleware for the development stack
10
- # stack(:middleware_name).use(MiddlewareClass)
11
- end
12
-
13
- # Add code to hooks. Default available hooks:
14
- # :before_build_stack, :before_mount_applications, :after_initialize_application, :after_build_stack
15
-
16
- # ProxyStack.before_build_stack do
17
- # # stuff to do
18
- # end
19
-
20
-