Created
September 13, 2011 22:54
-
-
Save typeoneerror/1215406 to your computer and use it in GitHub Desktop.
ssl route constraint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config/routes.rb | |
| AppName::Application.routes.draw do | |
| # API routing with versioned namespace | |
| scope :constraints => AppName::Ssl do | |
| namespace :api do | |
| namespace :v1 do | |
| # routes here | |
| end | |
| end | |
| end | |
| end | |
| # lib/app_name/ssl.rb | |
| module AppName | |
| class Ssl | |
| def self.matches?(request) | |
| return true if Rails.env.development? | |
| request.ssl? | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment