Created
November 26, 2018 01:36
-
-
Save mattgaidica/700de98e06a788191491830b9ff3236e to your computer and use it in GitHub Desktop.
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
class Myapi < Sinatra::Application | |
ActiveRecord::Base.default_timezone = :utc | |
configure :development, :test do | |
set :host, 'localhost:9999' | |
set :force_ssl, false | |
end | |
configure :staging do | |
set :host, 'my-api-staging.herokuapp.com' | |
set :force_ssl, true | |
end | |
configure :production do | |
set :host, 'my-api.herokuapp.com' | |
set :force_ssl, true | |
end | |
before do | |
content_type :json | |
ssl_whitelist = ['/calendar.ics'] | |
if settings.force_ssl && !request.secure? && !ssl_whitelist.include?(request.path_info) | |
halt json_status 400, "Please use SSL at https://#{settings.host}" | |
end | |
end | |
end | |
require_relative 'application/helpers/init' | |
require_relative 'application/routes/init' | |
require_relative 'application/models/init' | |
require_relative 'application/core_extensions/init' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment