Skip to content

Commit 117ce3f

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 117ce3f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/letsencrypt-rails-heroku/railtie.rb

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ class LetsencryptRailsHerokuRailtie < Rails::Railtie
33
Letsencrypt.configure
44
end
55

6+
initializer "letsencrypt_rails_heroku.configure_rails_initialization" do |app|
7+
if app.config.force_ssl
8+
app.middleware.insert_before ActionDispatch::SSL, Letsencrypt::Middleware
9+
else
10+
app.middleware.use Letsencrypt::Middleware
11+
end
12+
end
13+
614
rake_tasks do
715
load 'tasks/letsencrypt.rake'
816
end

0 commit comments

Comments
 (0)