Class: ActionDispatch::SSL
- Inherits:
-
Object
- Object
- ActionDispatch::SSL
- Defined in:
- lib/action_dispatch/middleware/ssl.rb
Constant Summary collapse
- YEAR =
31536000
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ SSL
constructor
A new instance of SSL.
Constructor Details
#initialize(app, options = {}) ⇒ SSL
Returns a new instance of SSL.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/action_dispatch/middleware/ssl.rb', line 9 def initialize(app, = {}) @app = app @hsts = .fetch(:hsts, {}) @hsts = {} if @hsts == true @hsts = self.class..merge(@hsts) if @hsts @host = [:host] @port = [:port] end |
Class Method Details
.default_hsts_options ⇒ Object
5 6 7 |
# File 'lib/action_dispatch/middleware/ssl.rb', line 5 def self. { :expires => YEAR, :subdomains => false } end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/action_dispatch/middleware/ssl.rb', line 20 def call(env) request = Request.new(env) if request.ssl? status, headers, body = @app.call(env) headers.reverse_merge!(hsts_headers) (headers) [status, headers, body] else redirect_to_https(request) end end |