Skip to content

Commit 5e1bb71

Browse files
committed
Insert Letsencrypt::Middleware dynamically
Since all we have to do is check for force_ssl I don't see why we can't just do that inside an initialize hook and change the way the middleware is inserted accordingly. Maybe I'm missing something obvious. This would reduce the amount of manual configuration required for this gem.
1 parent 72fe5a0 commit 5e1bb71

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/letsencrypt-rails-heroku/railtie.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ class LetsencryptRailsHerokuRailtie < Rails::Railtie
33
Letsencrypt.configure
44
end
55

6+
initializer "letsencrypt_rails_heroku.configure_rails_initialization" do |app|
7+
if Rails.env.production?
8+
if app.config.force_ssl
9+
app.middleware.insert_before ActionDispatch::SSL, Letsencrypt::Middleware
10+
else
11+
app.middleware.use Letsencrypt::Middleware
12+
end
13+
end
14+
end
15+
616
rake_tasks do
717
load 'tasks/letsencrypt.rake'
818
end

0 commit comments

Comments
 (0)