Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (23 sloc) 1.01 KB
require File.expand_path(File.dirname(__FILE__) + '/config/environment.rb')
require './app'
map '/api' do
use Middleware::FakeSession
use Middleware::AccessControl do |c|
c.origin '*'
c.route '/v1/courses', return_headers: %w{ETag Link}, methods: 'GET', accept_headers: %w{Authorization X-Requested-With}
c.route '/v1/courses/:id', return_headers: %w{ETag Link Last-Modified}, methods: 'GET', accept_headers: %w{Authorization X-Requested-With}
c.route '/v1/courses/:id/enrollments', return_headers: %w{ETag Link}, methods: %w{GET POST}, accept_headers: %w{Authorization Content-Type X-Requested-With}
c.route '/v1/tokens', methods: 'post', accept_headers: 'X-Requested-With'
end
use Warden::Manager do |c|
c.default_strategies(:simple_token)
c.failure_app = App
end
if ENV['MEMCACHE_SERVERS']
use Rack::Cache, metastore: Dalli::Client.new, entitystore: "file:tmp/cache/rack/body"
end
run Rack::Cascade.new [Api::CoursesController, Api::TokensController]
end
map '/' do
run App
end