rack-headercontrol 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- #Rack::HeaderControl
1
+ #Rack::Headercontrol
2
2
 
3
3
  Rack Middleware that allows you set/override response headers for selected paths
4
4
 
@@ -11,12 +11,30 @@ block for every condition that matches
11
11
  ##Usage
12
12
 
13
13
  ```ruby
14
- use Rack::HeaderControl do |change|
14
+ use Rack::Headercontrol do |change|
15
15
  change.path '/tralala' do |headers|
16
16
  headers['X-Foo'] = 'bar'
17
17
  end
18
+
18
19
  change.path /./ do |headers|
19
20
  headers.delete('X-Baz')
20
21
  end
22
+
23
+ # Serve CORS headers for webfonts to enable them in Firefox
24
+ change.path %r{\.(woff|ttf|otf)$} do |headers|
25
+ headers['Access-Control-Allow-Origin'] = '*'
26
+ end
27
+
28
+ # Set far-future expires headers for versioned assets
29
+ change.path %r{/style/longlived\.(.?)\.css} do |headers|
30
+ expires_at = 10.years.from_now.utc
31
+ max_age = (expires_at - Time.now).floor
32
+ headers['Expires'] = expires_at.rfc2822
33
+ headers['Cache-Control'] = "public, max-age=#{max_age}"
34
+ # Best practice not to send Etags /w far-future expiring assets
35
+ headers.delete('Etag')
36
+ headers.delete 'Pragma'
37
+ headers.delete 'Last-Modified'
38
+ end
21
39
  end
22
40
  ```
@@ -1,7 +1,7 @@
1
- require "rack-headercontrol/version"
2
-
3
1
  module Rack
4
- class HeaderControl
2
+ class Headercontrol
3
+ VERSION = "0.0.2"
4
+
5
5
  def initialize(app, &config_block)
6
6
  @app = app
7
7
  @config_block = config_block
@@ -22,6 +22,7 @@ module Rack
22
22
  end
23
23
  end
24
24
  end
25
+ HeaderControl = Headercontrol #Backwards-compatibility
25
26
 
26
27
  class PathRecorder
27
28
  def initialize
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "rack-headercontrol/version"
3
+ require "rack/headercontrol"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "rack-headercontrol"
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["gerrit@gerritkaiser.de"]
10
10
  s.homepage = 'http://github.com/gerrit/rack-headercontrol'
11
11
  s.summary = 'Rack Middleware that allows you set/override response headers for selected paths'
12
- s.description = ''
12
+ s.description = 'Can be used e.g. to set CORS headers or selective caching of resources'
13
13
 
14
14
  s.rubyforge_project = 'rack-headercontrol'
15
15
 
metadata CHANGED
@@ -1,87 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-headercontrol
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Gerrit Kaiser
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-10 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-10 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rack
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70112740907960 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- description: ""
36
- email:
23
+ prerelease: false
24
+ version_requirements: *70112740907960
25
+ description: Can be used e.g. to set CORS headers or selective caching of resources
26
+ email:
37
27
  - gerrit@gerritkaiser.de
38
28
  executables: []
39
-
40
29
  extensions: []
41
-
42
30
  extra_rdoc_files: []
43
-
44
- files:
31
+ files:
45
32
  - .gitignore
46
33
  - Gemfile
47
34
  - README.md
48
35
  - Rakefile
49
- - lib/rack-headercontrol.rb
50
- - lib/rack-headercontrol/version.rb
36
+ - lib/rack/headercontrol.rb
51
37
  - rack-headercontrol.gemspec
52
- has_rdoc: true
53
38
  homepage: http://github.com/gerrit/rack-headercontrol
54
39
  licenses: []
55
-
56
40
  post_install_message:
57
41
  rdoc_options: []
58
-
59
- require_paths:
42
+ require_paths:
60
43
  - lib
61
- required_ruby_version: !ruby/object:Gem::Requirement
44
+ required_ruby_version: !ruby/object:Gem::Requirement
62
45
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 3
67
- segments:
68
- - 0
69
- version: "0"
70
- required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
51
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
79
56
  requirements: []
80
-
81
57
  rubyforge_project: rack-headercontrol
82
- rubygems_version: 1.4.2
58
+ rubygems_version: 1.8.6
83
59
  signing_key:
84
60
  specification_version: 3
85
- summary: Rack Middleware that allows you set/override response headers for selected paths
61
+ summary: Rack Middleware that allows you set/override response headers for selected
62
+ paths
86
63
  test_files: []
87
-
@@ -1,5 +0,0 @@
1
- module Rack
2
- module Headercontrol
3
- VERSION = "0.0.1"
4
- end
5
- end