rack-toolbar 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/rack/toolbar.rb +10 -1
- data/lib/rack/toolbar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2fa79260febf1e4e9bc3a1501a406837e469968
|
4
|
+
data.tar.gz: 0b0bc306c4be9d1d06e459fb546bbdf59896bca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eca044f8154e63e07217228720a104c77e7dd26b59529bbfc33084494c7c4cb1e7ff6820be8323c4dc02fafde6cd45f22a2e5cc724c9524f996db339a03a1f8
|
7
|
+
data.tar.gz: ba25f077effb78e438df8b760d37dd2844986ce3c4592a41c8764d7d66031282461c6468a4cfc4a5c4bbc77520926a13ede0d2ba8a7cac884ea0359023b748b6
|
data/README.md
CHANGED
@@ -4,6 +4,9 @@ Allows you to create simple Rack Middleware that will insert HTML (or whatever!)
|
|
4
4
|
|
5
5
|
This gem was extracted from [Rack::Insight](https://github.com/pboling/rack-insight).
|
6
6
|
|
7
|
+
*NOTE*: As it goes with all middleware that modifies the response, not compatible with Rails' streaming responses
|
8
|
+
because it modifies the response.
|
9
|
+
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
Add this line to your application's Gemfile:
|
@@ -83,3 +86,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
83
86
|
## Contributors
|
84
87
|
|
85
88
|
See the [Network View](https://github.com/pboling/rack-toolbar/network)
|
89
|
+
|
90
|
+
## Alternatives
|
91
|
+
|
92
|
+
Other projects which will allow you to build Middleware to inject stuff into responses:
|
93
|
+
|
94
|
+
* [rack-plastic](https://github.com/techiferous/rack-plastic)
|
data/lib/rack/toolbar.rb
CHANGED
@@ -35,10 +35,19 @@ EOS
|
|
35
35
|
|
36
36
|
# Subclasses may override this method if they have alternate means of deciding which requests to modify.
|
37
37
|
def okay_to_modify?
|
38
|
-
return false
|
38
|
+
return false if is_xhr?
|
39
|
+
return false unless modifiable_content_type?
|
39
40
|
true
|
40
41
|
end
|
41
42
|
|
43
|
+
def modifiable_content_type?
|
44
|
+
@headers["Content-Type"] =~ self.class::CONTENT_TYPE_REGEX
|
45
|
+
end
|
46
|
+
|
47
|
+
def is_xhr?
|
48
|
+
@headers["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
|
49
|
+
end
|
50
|
+
|
42
51
|
def each(&block)
|
43
52
|
if okay_to_modify?
|
44
53
|
body = ""
|
data/lib/rack/toolbar/version.rb
CHANGED